Search Unity

Video VideoPlayer: Prepare Event Only Called Once

Discussion in 'Audio & Video' started by gamecakestudios, Jan 7, 2019.

  1. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
    Using: Unity 2018.2.7f1, but tested and saw similar behavior on 2018.3. Happens in Editor and on iOS as well.

    Hello! We have been using Unity's VideoPlayer to display streamed animated GIFs. However, we wanted to start using the "prepareCompleted" callback, but have been seeing some weird behavior. It appears as though the callback is only triggered the first time a video is prepared. After that, when using Prepare(), we only see the prepareCompleted event AFTER we try to play the video, which makes it somewhat worthless. This happens even if we explicitly Stop the previous video we were using. It also still happens with different VideoPlayers; we used two different video players and wanted to cycle the preparations between them, but we still only ever receive the initial callback from the first VideoPlayer, and the second player never manages to trigger the callback properly.

    I guess my question is; does anyone know any good workarounds for this, or how to get Prepare() to behave properly? I'd rather not have to switch to a different video play system, but it's starting to look as though that might be necessary.
     
  2. WashingMachine

    WashingMachine

    Unity Technologies

    Joined:
    Mar 23, 2017
    Posts:
    24
    Hey! Sounds like it could be a bug.
    If you output the VideoPlayer.isPrepared value after VideoPlayer.Stop() was invoked, what do you see?
    Is it always false?
    Have you tried removing the reference to your video and then adding it again between plays?
     
  3. gamecakestudios

    gamecakestudios

    Joined:
    Nov 13, 2013
    Posts:
    21
    Hey WashingMachine, we figured out what was going on, finally. The GameObject the VideoPlayer was attached to was being deactivated, which appears to disable the caching system. Thanks for the response, though!
     
    WashingMachine likes this.