- Home /
How to check if Handheld.PlayFullScreenMovie has stopped playing
Hi,
I'm using "Handheld.PlayFullScreenMovie" to play an intro movie for my game on Android.
How can I check if the user has cancelled the playback (FullScreenMovieControlMode.CancelOnInput is on) or the movie has ended?
I would like to load a menu / level after that.
Little code snippet:
void Start() {
Handheld.PlayFullScreenMovie ("LogoAnim_480.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
}
Answer by tsmitro · May 21, 2013 at 03:38 PM
From the Unity reference for Handheld.PlayFullScreenMovie:
Calling this function will pause Unity during movie playback. When playback finishes Unity will resume.
You can handle this in a coroutine and yield until playback has finished or been halted:
void PlayVideo(string videoPath)
{
StartCoroutine(PlayVideoCoroutine(videoPath));
}
IEnumerator PlayVideoCoroutine(string videoPath)
{
Handheld.PlayFullScreenMovie(videoPath, Color.black, FullScreenMovieControlMode.CancelOnInput);
yield return new WaitForEndOfFrame();
Debug.Log("Video playback completed.");
}
I tried that and my debug statement executed instantly. Then i tried:
private IEnumerator PlayStrea$$anonymous$$gVideo(object URL) {
Handheld.PlayFullScreen$$anonymous$$ovie((string)URL, Color.black, FullScreen$$anonymous$$ovieControl$$anonymous$$ode.Full, FullScreen$$anonymous$$ovieScaling$$anonymous$$ode.AspectFill);
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
Debug.Log("Video playback completed.");
}
and my debug didn't execute til the video was ended via video complete or done/cancel input
Thank you @AT$$anonymous$$Ethan
It actually required
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
to make it work
Answer by mostafanastary · Mar 01, 2020 at 12:31 PM
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
not working for me, please help!
Your answer
Follow this Question
Related Questions
how to play video on android 4 Answers
Android - Play movie with Handheld skips it 0 Answers
Handheld.PlayFullScreenMovie() works on Android but not iOS? 2 Answers
Android Handheld.PlayfullscreenMovie not working from Cloud Build 1 Answer
is Handheld.PlayFullScreenMovie a pro feature in unity? 1 Answer