Search Unity

Resolved Quest 2 VideoPlayer from URL is White

Discussion in 'VR' started by PsiconLab, Mar 20, 2021.

  1. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    I'm trying to load a video from a URL at runtime in VR on the Quest 2 and display it on a texture.

    I've put the file location in the URL of the videoplayer and it works fine in the Unity Editor, but when I build for the Quest the video does not load into the texture and play.

    I think what I need to find out is where Unity is storing the video file on the Quest. I can't find it any where! I've used adb's find command to search the external storage, and looked in the Application.persistentDataPath but I can't find it.

    Any advice on what I'm doing wrong?
     
    Last edited: Apr 3, 2021
  2. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    Ok, so I finally found a way to make this work... I downloaded the video to the persistent storage first, and then set the path (URL) using downloadHandler, finally set the URL to that location.

    Something like this...

    Code (CSharp):
    1. var webRequest = UnityWebRequest.Get(url);
    2. string path = Path.Combine(Application.persistentDataPath, file_name + ".mp4");
    3. webRequest.downloadHandler = new DownloadHandlerFile(path);
    4. yield return webRequest.SendWebRequest();
    5. if (webRequest.result == UnityWebRequest.Result.Success)
    6. {
    7.         videoPlayer.url = path;
    8.  
    9.         Debug.Log("File successfully downloaded and saved to " + path);
    10.  
    11.         StartCoroutine(PlayVideo());
    12. }
     
    Last edited: Apr 3, 2021
    OrtegaLabs likes this.
  3. OrtegaLabs

    OrtegaLabs

    Joined:
    Jan 14, 2022
    Posts:
    1
    It is unfortunate the video file must be downloaded and stored on the Quest 2 before playing. As you know, the video streams fine in the Unity editor. That is, when the player's source is set to VideoSource.URL and the URL is set to a valid MP4 URL. Having to download the file rather than streaming is not viable for me since I deal with many large videos. Do you prefer streaming? If so, have you found any alternatives to allow for streaming?
     
  4. unity_9848D953D9AFC959906E

    unity_9848D953D9AFC959906E

    Joined:
    Apr 12, 2021
    Posts:
    1
    I had the same issue, the video player did not play the video when fetched from a URL. In my case the URL was a (http) and not (https). So adding the following in the AndroidManifest fixed it for me.

    android:usesCleartextTraffic="true"