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. Dismiss Notice

Question Can't load video from the persistentDataPath on Quest 2

Discussion in 'Audio & Video' started by TropicalCyborg, Jul 10, 2023.

  1. TropicalCyborg

    TropicalCyborg

    Joined:
    Mar 19, 2014
    Posts:
    28
    I need to display a very large 360 video on a VR application. I've already done the skybox and Render texture setup and its working fine but as the video file is too large the application does'nt buid. The solution I am trying is to load the video from the persistent data path using a script. Although the app is able to locate the video clip on the local storage, for some reason it's not playing. Can somebody help me? The script I wrote is the following:


    Code (CSharp):
    1.   [SerializeField]
    2.   TextMeshPro text;
    3.  
    4.     [SerializeField]
    5.     VideoPlayer player;
    6.  
    7.     private string path;
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.         path = Application.persistentDataPath;
    12.         path = Application.persistentDataPath + "/JbRedimensioned.mp4";
    13.         text.text = path;
    14.         player.source = VideoSource.Url;
    15.         player.url = path;
    16.  
    17.         if(player.clip != null)
    18.         {
    19.           string clip = player.clip.name;
    20.           clip = clip + player.clip.length.ToString();
    21.           text.text = clip;
    22.           player.Prepare();
    23.           player.waitForFirstFrame = true;
    24.           if(player.isPrepared)
    25.           {
    26.             player.Play();
    27.           }
    28.         }else
    29.         {
    30.           path = path + "__ no clip";
    31.           text.text = path;
    32.         }
    33.     }
     
  2. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    502
    Prepare is asynchronous. So it is totally possible that isPrepared is false. You should just call Play instead since Preparing just before Play is useless. You need to call Prepare at least 1-2 seconds before you call Play if you want to accelerate the opening.