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

Get smartphone video resolution

Discussion in 'Scripting' started by adria_ec, Sep 16, 2015.

  1. adria_ec

    adria_ec

    Joined:
    Sep 16, 2015
    Posts:
    6
    Hi, I'm trying to build an app for iOS and Android that plays video and I'm using the plugin Easy Movie Texture for that. I would like to have different video resolutions to display and show one or another depending on the Smartphone resolution.

    The problem is that, for example, iPhone 5 has a screen resolution of 640×1136, but it plays videos at 1920x1080. Screen.width and Screen.height give me the 640×1136, is there any way to get the display video resolution of the smartphone to play the video at the max resolution? I can't find any solution and I'm a little desperate.

    Thank you.
     
  2. adria_ec

    adria_ec

    Joined:
    Sep 16, 2015
    Posts:
    6
    I finally solved this, here's the solution if anyone is interested.

    In a new script, I start "WebCamTexture" with a high resolution, if your device has a smaller resolution it will give you the maximum. Then, use width and height to get the resolution of your camera, that use to be the same resolution your device can play.

    voidStart () {

    WebCamTexture wct = newWebCamTexture (3840, 2160);
    wct.Play ();

    int w = wct.width;

    wct.Stop ();

    }
     
    Esera, artur-leao and LeftyRighty like this.
  3. Esera

    Esera

    Joined:
    Feb 20, 2017
    Posts:
    9
    Thank you soo much for your answer!!

    However: I still get the screen resolution and not the playable video resolution.

    example: Screen resolution is 1920x1080, but 4k videos can be played and filmed. I still get 1920 for width and 1080 for height.
     
    Last edited: Mar 22, 2017