Most people will use Unity for building HoloLens applications. It is a rich environment which allows you to quickly build your scene and add additional scripts for handling all functionality. It is really cool to expand your HoloLens applications with sound and video.
New video player component
With the new version of Unity we have the component Video Player which can be used to embed a video from your assets or by URL to any GameObject. This new video feature introduced in Unity 5.6 supersedes the old Movie Textures feature. This allows us to quickly incorporate a video into your HoloLens application. But since there is no document except for a draft document, some explanation on how to enable sound for your video is needed.
How to use the Video Player component
In our example i’m working on a HoloLens application for one of our company events. The HoloLens app is called HoloBooth and shows a cool bus stop containing information and video. The glass is used to show videos on. To place the video on one of the glasses in the back, you will need to add the component “Video Player” to the glass Game Object. In this case we have added a HoloLens video in the assets folder.
The video is selected through the video clip property and have the source set to Video Clip. Because we want to have the video started as soon as the application runs, the Play on Awake option is selected. Because we have added the component to the Glass GameObject, its render mode and Renderer properties are set.
More information on the Video Player can be found here.
How to enable sound for the Video Player
But when you run it within Unity or on the HoloLens there is no sound. You will need to specify an Audio Source to output the sound of the video. At the same GameObject add an Audio Source component. Deselect the option Play on Awake. And because we are developing for HoloLens we want to use spatial sound. Make sure that spatial sound is set to 1. No other settings are needed.
We need to change some properties on the Video Player component to get the sound from the video to the audio source. Set the Audio output Mode property to “Audio Source”. Select the glass GameObject as the Audio Source. In principal you select a GameObject containing an Audio Source component.
And voila! We have sound from the video 🙂
Minimal HoloLens settings
Next to the standard HoloLens settings needed when creating HoloLens projects with Unity, it is important to configure the player settings with some specific capabilities. The following capabilities need to be selected
Sound location of the video player
You will need to take something in consideration when using spatial sound. It is possible to use any GameObject containing an Audio Source component as output for the video sound. But that means that spatial sound will use the location of that other GameObject to produce the sound. If that GameObject is not near the video you will get strange effects because of it. The sound doesn’t come from the video but instead of another located GameObject. This could be intentional when you have for example speakers in your scene and wants to have the sound coming from those speakers.