Search Unity

Video VideoPlayer black screen problem

Discussion in 'Audio & Video' started by matbee04, Mar 7, 2021.

  1. matbee04

    matbee04

    Joined:
    Jan 30, 2018
    Posts:
    5
    I have some problem with VideoPlayer. In editor everything looks good, but when I run application on Android device, before play video a black screen appears for a very short time
     
    Arash_dh likes this.
  2. AsifNaeem

    AsifNaeem

    Joined:
    Apr 12, 2016
    Posts:
    29
    Facing same issue in Unity 2021.3.12
     
  3. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    If you are using a RenderTexture, check that the RenderTexture is clear before showing it. Otherwise, can you check if the first frame of your clip is black? If you click on your video and play the preview, you shouldn't see any black frames.
     
  4. Xesk

    Xesk

    Joined:
    Dec 26, 2017
    Posts:
    15
    Hi, same issue here.

    My videos don't have any black frame.
    Tried to clear the RenderTexture before Play():
    Code (CSharp):
    1. public void PlayVideo()
    2. {
    3.     ClearRenderTexture();
    4.     videoPlayer.Play();
    5. }
    6.  
    7. private void ClearRenderTexture()
    8. {
    9.     RenderTexture rt = RenderTexture.active;
    10.     RenderTexture.active = videoPlayer.targetTexture;
    11.     GL.Clear(true, true, Color.clear);
    12.     RenderTexture.active = rt;
    13. }
    Also tried clearing on Start().

    I'm thinking about doing some trick with, so maybe somehow I can load the first frame preemptively...
    Code (CSharp):
    1. videoPlayer.Play();
    2. videoPlayer.Stop();
     
    kyoa likes this.
  5. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Don't do Play() Stop(). If you want, you can Play() Pause() instead. Maybe try another colour like red to see if it shows like expected. If you don't see any difference, perhaps there is an issue elsewhere.
     
  6. kyoa

    kyoa

    Joined:
    Jan 31, 2021
    Posts:
    1
    Same issue, don't know how to remove this black screen
     
  7. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Code (CSharp):
    1. private void ClearRenderTexture()
    2. {
    3.     RenderTexture rt = RenderTexture.active;
    4.     RenderTexture.active = videoPlayer.targetTexture;
    5.     GL.Clear(true, true, Color.clear);
    6.     RenderTexture.active = rt;
    7. }
    This code should work. I would check if the targetTexture is not null and what you expect. Maybe you are not clearing the RenderTexture you are showing, but another one.