- Home /
Movie Texture Duration Returns -1
Hey guys, This is the result I get of a video that plays fine in unity, doing a print right after the Play() function. Format is OGV I would like to get this resolved instead of doing isPlaying.
Any ideas will be greatly appreciated.
Answer by Gogoriko · Sep 19, 2013 at 12:42 PM
Before you call the Play() function, the duration is -1.
cf. http://forum.unity3d.com/threads/121989-MovieTexture-duration-does-not-work-with-OGV-videos
I have the duration function's result printed to console even during and after the movie has played and its still at -1.
Same issue here, debugging a WaitForEndOfFrame afterwards and still getting -1.
Answer by yu.wan · Apr 06, 2016 at 09:29 AM
the duration will be -1 for some reason, but I successfully find a workaround:
IEnumerator playVideoList() { Renderer fr = GetComponent(); fr.material.mainTexture = videoList[0]; MovieTexture fmovie = (MovieTexture)fr.material.mainTexture; fmovie.Play(); AudioSource faud = GetComponent(); faud.clip = fmovie.audioClip; faud.Play();
//yield return null;
while (true)
{
Renderer r = GetComponent<Renderer>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
if (!movie.isPlaying)
{
if (idx == videoList.Length - 1) break;
r.material.mainTexture = videoList[++idx];
movie = (MovieTexture)r.material.mainTexture;
movie.Stop();
movie.Play();
AudioSource aud = GetComponent<AudioSource>();
aud.clip = movie.audioClip;
aud.Stop();
aud.Play();
}
yield return new WaitForFixedUpdate();
}
}
Your answer
Follow this Question
Related Questions
MovieTexture duration 2 Answers
How do I play a full screen video? 4 Answers
Using a GUI Movie Texture (making it appear and disappear correctly) 2 Answers
How to use FullScreenMoviecontrolMode 0 Answers
Loading Screen 2 Answers