I am using following code to play a movie file in unity.
the problem i am having is I can’t find out the duration of the movie. I want to load next scene after the end of the movie.
void Start () {
wwwData = new WWW(url);
guiTexture.texture = wwwData.movie;
movieTexture = guiTexture.texture as MovieTexture;
}
void Update ()
{
if (!movieTexture.isPlaying && movieTexture.isReadyToPlay)
{
audio.clip = movieTexture.audioClip;
audio.Play();
movieTexture.Play();
WaitTillMovieIsOver();
}
}
IEnumerator WaitTillMovieIsOver()
{
Debug.Log("started movie");
while(movieTexture.isPlaying)
{
yield return null;
}
Debug.Log("movie over");
}
wwwData.movie.duration always return -1
for some reason WaitTillMovieIsOver is also not getting called …
can anyone provide some help on this?