HoloLens: How to Play Videos with Unity.

If you need to display a video in a Unity application, there are several methods to accomplish this. Each method is designed for a specific operating system.  Below are some tips for displaying videos in iOS, Android and the latest version of Unity.

 

In order to make a video playable for later distribution on the HoloLens, the video file must be of an acceptable format and compression. The simplest version for building to the HoloLens would be to create an appropriate Movie Texture and audio source for the video. Unfortunately for iOS, the local machine cannot use Movie Textures for any build, as Movie Texture files are not supported on iOS.   The build should be a full-screen streaming playback which is provided using the Handheld.PlayFullScreenMovie scripts, only relating to videos of the compression format of H.263, H.264 AVC, or MPEG–4 SP.

 

For builds that would be applied to an Android device, using the same method to build as in iOS can be used.

 

For Windows, version 5 of Unity is able to read MP4, MOV, and 3GP video files with the intention of converting them into an Ogg Theora format, which is readable for Unity as a Movie Texture. To ensure the default compression of any video that would be placed into Unity, it will be converted and read as an Ogg Theora.  Before Unity can open the video file, it must first be opened and saved in an updated version of QuickTime. No other changes are necessary to make the conversion work. From there, place the Movie Texture file onto a Raw Image, create the Audio Source with the attached audio file.  The audio file will be a child of the Movie Texture, if an applicable one was created. Then you can construct how you wish to have the video run in the script. Video files may have issues with playing when brought into Unity.  If this is the case, check the duration of the video file. If it is too long or gets cut off from playing the full video, reduce the quality of the Movie Texture file in Unity’s Inspector window.  If the video is about ten minutes or longer, events in the scene may freeze or lag the video as they take up processing speed to run simultaneously.  The recommended quality of the video on the HoloLens should be set to .1 for a duration longer than five minutes to experience minimum resolution reduction.  Experimenting with how the video plays in the local scene with the current build on the HoloLens can result in better play speeds without framerate drops or blurry resolution.  With these tips and some basic troubleshooting, videos will play in Unity for the HoloLens.