Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Loading and Playback

Discussion in 'VR' started by charlie-peter, Mar 20, 2017.

  1. charlie-peter

    charlie-peter

    Joined:
    Dec 14, 2015
    Posts:
    9
    Unity 5.5.1f1
    Hey guys I'm trying to load and play captured HoloLens videos and videos in general in my Unity app. The point is to be able to place a related video next to a event that's happening.

    Code (CSharp):
    1. IEnumerator LoadMovieTextureFromFile(string fileName)
    2.     {
    3.         Debug.Log(videoFolderPath + "\\" + fileName);
    4.         WWW www =  new WWW(videoFolderPath + "\\" + fileName);
    5.  
    6.         while (!www.isDone)
    7.         {
    8.             Debug.Log("Loading...");
    9.             yield return null;
    10.         }
    11.  
    12.         Debug.Log(www.movie.duration + " <--- wwww");
    13.  
    14.         if (www.error != null)
    15.         {
    16.             Debug.Log("Error: Can't laod movie! - " + www.error);
    17.             yield break;
    18.         }
    19.  
    20.         MovieTexture video = www.movie as MovieTexture;
    21.         Debug.Log("Movie loaded");
    22.         Debug.Log(www.movie);
    23.  
    24.         renderMat.material.mainTexture = video;
    25.         video.Play();
    26.     }
    Here is a sample of my code that loads and attempts to play the video. www.error is not happening so I assume the video is loaded correctly.

    The play surface is a panel with a Material using the sprites/Default shader.

    Also a note HoloLens does capture in .mp4 which I've heard has issues with Unity, but I've also seen posts where it seems like people are loading them fine and just experiencing lag.
    ( https://forums.hololens.com/discussion/423/movietexture-on-hololens )
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Hello,

    When you run this code are you seeing any issues or errors in the log? It might help to get the response from the site you are trying to pull the video from.

    Thank you,
    Wesley
     
  3. charlie-peter

    charlie-peter

    Joined:
    Dec 14, 2015
    Posts:
    9
    There aren't any errors that I see, and I'm loading the video in from a folder on the HoloLens so there isn't really a "other side". When I was looking for ways to load in .mp4's this is what I found.
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    I would try to get the response just in case there is something there that could give you a idea of the issue. What is the string for the video path that you are trying to pass? There seems to be a few missing pieces here that you would need to make a url connection using WWW to the Hololens.

    Another way may be to use the Rest API commands using the Mixed Reality Capture Commands
    https://developer.microsoft.com/en-...ce_portal_api_reference#mixed_reality_capture

    Have you tried using the File system instead of WWW to reach the folder you need?

    i.e.
    #if UNITY_EDITOR
    string m_FileNameCSV = @"C:\Users\Wesley\Desktop\" + DateTime.Now.ToString("yyyyMMdd_HH-mm") + "Data.csv";
    #else
    string m_FileNameCSV = Path.Combine(Application.persistentDataPath, string.Format(DateTime.Now.ToString("yyyyMMdd_HH-mm") + @"_Data.csv"));
    #endif

    example I use to write files with data to the hololens, it might work to pull a file as well
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644