Everything Altspace

How to Enable Volume Controls for Audio and Video in Unity

0
(0)

What You’ll Need

  • Altspace World and custom Template
  • Unity Project setup to upload to the Template

Setup a Audio Mixer

Create an Audio Mixer called Main in your project’s Assets folder at the top level.

Double-click it and add groups Environment and Effects under Master. It’s important to name these exactly as shown.

Success!

Enable Volume Controls for Audio

Find a sample audio file — maybe one of these:

https://freemusicarchive.org/music/charts/all/

Download and drag it into your project.

Drag it into the scene and select Environment as the AudioMixerGroup for the Audio Source’s Output.

Check Play on Awake and Loop so it’s easier to test.

Save and upload. In Altspace, enter your World and you should hear the short clip looping. Navigate to Menu > Settings > Audio > Environment Volume and try lowering and raising the volume.

Voila! If you want to have it controlled by the Effects Volume settings, select the Effects AudioMixerGroup next time. These are the only two groups that users can control.

Enable Volume Controls for Video

Find a sample video file — here’s one from Wikipedia:

Download and drag it into your project. This creates a Video Player object.

Create a Render Texture in your Assets Folder.

Find the dimensions of your video by right clicking it and selecting Properties in Explorer.

Set the Size accordingly.

Click your Video Player and set Render Mode to Render Texture.

Choose the Render Texture you just made as the Target Texture.

Create a Quad with Scale having the same aspect ratio — in this case 2.45×1

Temporarily put a Camera facing your screen in the scene to test that the video is rendering properly (the Uploader will automatically delete the Camera when building).

Click Play and verify that the video plays and you hear audio.

Right click in your Hierarchy and create an Audio Source.

Set Output to Environment.

Go back to your Video Player and set Audio Output Mode to Audio Source and set the Audio Source to what you just made.

Save and upload. In Altspace, enter your World and you should see and hear the video looping. Navigate to Menu > Settings > Audio > Environment Volume and try lowering and raising the volume.

Magnifique! You should hear the volume of both the audio and video clips you embedded changing as you adjust the Environment Volume.

FAQ

  • When I change the Environment Volume setting in Altspace nothing happens? Double check that everything is named exactly as specified in the Audio Mixer. Make sure the Audio Mixer is at the top level of the Assets folder. If you used lower case “environment”, that would break it. Navigate to your Template on altvr.com to verify that your upload succeeded and then reset your World.
  • Why can’t I hear the audio clip? Some audio just won’t play properly. Try another one. I’ve had success with .mp3 and .ogg formats.
  • Why does my video play in Unity but not in Altspace? Some videos just don’t play properly. Try another one. I’ve had success with .mp4 and .ogv formats.
  • What about “Effects Volume”? For audio that’s controllable under Menu > Settings > Audio > Effects Volume, use the mixer group called Effects.
  • Would this work for Kit items? Haven’t been successful in my tests so far.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?