Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

VideoPlayer.Prepare broken

Discussion in '5.6 Beta' started by readme, Mar 20, 2017.

  1. readme

    readme

    Joined:
    Jan 2, 2014
    Posts:
    3
    Hello everyone,

    back in b3 I tried the new VideoPlayer out and came back to see what changed (I had frozen video issues back then).
    To my surprise the Prepare() method seems to be broken, and I also tried with b10 - same behaviour. Still works back in b3. How has this not been reported already?
    Back then I was using a CoRoutine that would yield while the VideoPlayer was not yet prepared, and tried the "new" prepareCompleted callback. Same issue.

    On a second note, when playing a video on awake, "Wait For First Frame" makes the video not play entirely (works without).

    Please check this project that shows the behaviour:
    https://we.tl/M1mpWjs3td

    Setup: no video file shipped (tried many different ones, so that's not the problem), please put your videofile in the PlayVideo Script's Clip Field. Playback/Loading is delayed by 5 seconds, prints out to console.

    Thanks!
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi readme!

    The video doesn't play in your scene because you never call the VideoPlayer.Prepare() method. Videos don't auto-prepare; this has to be done explicitly. With this call added in your Start() method, your scene works as expected.

    About the Wait For First Frame not playing the video entirely, can you elaborate? Are you saying the video stops before the end, or starts after the beginning? Note that this feature is currently disabled unless you specify play-on-awake (will be fixed in the release so it works independently of play-on-awake).

    Thanks for trying this out, and please log bugs with your findings if possible so we have the full details (platform, project, movies used, etc.).

    Dominique
    A/V developer at Unity
     
  3. readme

    readme

    Joined:
    Jan 2, 2014
    Posts:
    3
    Hi Dominique,
    thanks for your reply.
    You got me puzzled there ... I do call the .Prepare() method in my Update loop:
    _videoPlayer.Prepare();

    Adding it to Start() would just trigger the callback and set isPlaying to true, no?
    Making the assumption that the callback is fired even if there's nothing to prepare at the time (no clip).
    I thought the Prepare method's job is to load a video's first frame into memory so you can start instantly start playing without lacking any frames.

    Concerning Wait for First Frame:
    "not playing entirely" means: it doesn't even start ... seems like this could be traced back to the other problem's origin, as "Wait For First Frame" kind of sounds like what I thought Prepare() was doing?

    Thanks

    Update: also found this http://stackoverflow.com/questions/...y-videoplayer-and-videoclip-api-to-play-video which also describes a "Stuck at "Preparing Video" issue.
    Waiting for xx seconds is not a valid workaround in my case, as I need to instantly play another video after the preceding one stopped.
     
    Last edited: Mar 21, 2017
  4. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Ah yes, you're right. The Clip property on your Script has to be set to the wanted Video Clip; I hadn't seen this and had set the clip on the VideoPlayer component instead, my bad. I removed my edit of your script and set the Clip property on your Play Video script instead, and now it starts as expected after 5 seconds. So what you may be observing is bugs that were present in b10: more specifically with clips whose first frame index is 1 instead of 0. Please make sure you retry with the latest version; b11 addresses this specific issue.

    Wait for first frame means that if you start playback without having prepared the clip first, then the player will make this preparation itself before allowing the clip time to start increasing. As mentioned in my previous e-mail, this mechanism only works with play-on-awake in the version you're using, but the final release addresses this.

    Again, I retried using the changes I described above but with wait-for-first-frame enabled, and the clip also starts as expected without any visible skip at the beginning. Note I am trying this on the 2nd candidate for the final release, so the version you are using will not (yet) have this expected behaviour, but it will be present in the final release.

    The suggestion to wait (a few game frames, not seconds) is only applicable for situations where playback starts while the scene is loading (such as when play-on-awake is enabled). As you certainly know, the first few frames are taking a lot longer than during normal execution when Unity is loading a scene; the suggestion is just to skip these few frames to avoid the scene-loading process from interfering with the playback.

    Thanks for testing and reporting this!

    Dominique
     
  5. readme

    readme

    Joined:
    Jan 2, 2014
    Posts:
    3
    Hi Dominique,

    thanks for your reply.
    I am using the latest Release Candidate f1, so the bug that was supposedly addressed in b11 isn't fixed yet apparently.
    Sorry, reading my initial post this wasn't clearly mentioned.

    Have you tried f1 to confirm my observings? Because neither b10 nor f1 works for me, will also check b11.
    Probably it's been fixed for f2 only ... is it released within the very next days, as I was asked by some students to put together a little something for their thesis (needs to be done by Monday)
    Otherwise I'll stick to b3 for now, as clip preparation still worked back then.

    Thanks for your time!