- Home /
IS Videoplayer.preparecompleted pointless?
So I assumed Videoplayer.preparecompleted would trigger when the video is prepared. I assumed that meant the video was fully loaded and ready to play front to back with not needing to download anymore. but when using it, it looks like it means all prep was made to get the video player ready to play and can start playing it, but no promises to how much of the video is loaded. If I call video.prepare and wait to play on preparecompleted it video does not play, it shows the first frame and freezes. It works better to just use .play, but then after a few seconds it stops due to needing to load.
All i want is a way to track load progress. I want to be able to know how much of my video from url is loaded, so i know when it is safe to start playing the video with no interruptions.
Answer by Virat-Gangurde · Jul 04, 2020 at 10:52 AM
Hi!
The usual way to play a movie from the web, with Unity, is to point the VideoPlayer to the movie using the VideoPlayer.url property and calling Play(). But this, as you are pointing out, does not report buffering progress and is indeed a missing feature in the VideoPlayer that we may address eventually.
Here are two options; none of them is perfect but maybe adequate for your use case: Instead of calling VideoPlayer.Play() immediately, you can add a handler on the VideoPlayer.prepareCompleted event and then call VideoPlayer.Prepare(). This does not expose progress, but at least you can have a spinning cursor in the mean time and have it disappear as soon as buffering is considered sufficient to start playback. If it's acceptable for you to not start the playback until the movie is fully downloaded, then you can just use UnityWebRequest.Get directly to download the file locally. This will get you the same progress reporting that you're using for textures. Once downloaded, you can have your VideoPlayer use the local file by setting the VideoPlayer.url property to the filesystem path of the downloaded file. Hope this helps,
Your answer
Follow this Question
Related Questions
Can handheld.PlayfullScreenMovie() work with Vr view to play 360 degree video using google vr sdk? 0 Answers
play back 360 video STEREO on GearVR 1 Answer
pre-prepare video in scene before its needed 0 Answers
Trouble getting Google GVRVideoPlayer to Implement in Unity 5.6.2 with Google Cardboard v1.60 0 Answers
How to play video on WEBGL 0 Answers