Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to find out video resolution after prepareCompleted in videoplayer

Discussion in 'Scripting' started by wesloc, May 20, 2017.

  1. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    Hi Everyone:

    In the new 5.6 VideoPlayer, after the prepareCompleted event, how do I query the resolution of the video?

    I am using video url instead of clip. Therefore, the clip is null when receiving the prepareCompleted event.

    When receiving prepareCompleted, frame rate and frame count are available. I am surprised that the width and height are not available through similar interfaces.

    I am hoping that by querying the width and height, I can allocate a RenderTexture that has the same size as the video. This RenderTexture will be used as the targetTexture of the video player.

    I have one idea that I have not tried yet. Setting the renderMode to APIOnly and check the size of the VideoPlayer.texture. However, this seems to be an awful lot of work for information that must be already known inside the VideoPlayer.

    Thanks in advance.

    Cheers,
     
  2. wesloc

    wesloc

    Joined:
    Feb 4, 2017
    Posts:
    14
    Hmmm...

    It looks like that when receiving the PrepareCompleted event, the VideoPlayer.texture did get set to the size of the video.

    I guess my question is answered. However, it is still my believe that explicit interfaces similar to frameRate and frameCount would be nicer.

    Cheers,