Search Unity

Video VideoPlayer with Target Texture stays black after game in background

Discussion in 'Audio & Video' started by drorriov, Jan 19, 2019.

  1. drorriov

    drorriov

    Joined:
    Jun 7, 2014
    Posts:
    43
    Hello,

    I have a steaming unity videoplayer component who plays a video from a URL.

    Sometimes a user can put the game in the background. i detect this with
    Code (CSharp):
    1. OnApplicationFocus(bool focus)
    than I Pause playback.
    When returning back I Play to continue the video from where it paused.

    But the Target Texture can stay black or show a static frame of the video. I did notice it sometimes works correctly, but most won't.
    Note that Audio always pauses and continue perfectly.
    Anyone is familiar with this situation or knows how to solve it?

    Using unity 2018.3.2f
     
  2. ClosingTime

    ClosingTime

    Joined:
    Nov 23, 2016
    Posts:
    241
    Not sure, maybe you can try to create it again and play it from the frame you stopped.
    Also, in OpenGL when you minimize an app, textures might need to be freed.
    It is possible that Unity frees your render texture and recreates it, but it didn't update the reference in VideoPlayer? not sure.
     
  3. drorriov

    drorriov

    Joined:
    Jun 7, 2014
    Posts:
    43
    Note that it happens with Android.
    I use VideoPlayer with Canvas. It's like Canvas overlay fails to refresh texture on android after pause.
     
  4. ClosingTime

    ClosingTime

    Joined:
    Nov 23, 2016
    Posts:
    241
    I think Canvas would also use OpenGL underneath.
    My only suggestion is to try and recreate the VideoPlayer before you get back as I know that in Android OpenGL buffers need to be destroyed before you pause.