Search Unity

Unity Video Player - Issues

Discussion in 'Scripting' started by john-essy, May 4, 2018.

  1. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    Hi there,

    I have an issue with the video player, when i press play it plays the sound but no video is shown.

    upload_2018-5-4_17-37-19.png

    It shows in the preview window but not on the raw image!

    Code (CSharp):
    1.     RenderTexture text;
    2.     public VideoPlayer player;
    3.     public RawImage image;
    4.     public AudioSource audioSource;
    5.  
    6.     void Start()
    7.     {
    8.         text = new RenderTexture((int)player.clip.width, (int)player.clip.height, 0);
    9.  
    10.         player.targetTexture = text;
    11.         player.renderMode = VideoRenderMode.RenderTexture;
    12.         image.texture = text;
    13.  
    14.         Vector3 scale = image.transform.localScale;
    15.         image.transform.localScale = scale;
    16.  
    17.         player.audioOutputMode = VideoAudioOutputMode.AudioSource;
    18.         player.SetTargetAudioSource(0, audioSource);
    19.  
    20.         player.source = VideoSource.VideoClip;
    21.         player.Play();
    22.     }
    This is what i am using to play the video.

    Does anyone know why this is happening.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Does the video clip play when you double click on the video file in the file system and play it? Windows or Mac?
     
  3. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    It does mate yeah, and its on windows.
     
  4. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    Ok so i set up a new player, and for some reason its now working. Weird.
     
  5. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    On another note, do you know how i could get a thumbnail of the video? All the videos will be setup by the client and we need a way to show thumbnails directly from the video file?