How to mute/lower sound in Media Player

Ok, a lot of people seem to have the problem of NOT playing sound, I have the opposite problem:

In my scene I have a number of TVs playing a video; I want them to be muted, until the player triggers something and the audio starts again. How can I do that?

I’m guessing the sound mix could be of some use, but I don’t get how to combine it in my blueprints.

There are multiple Sound nodes you can use, which one are you using?

That’s the point - I’m not using Sound nodes, I’m using a MediaPlayer , which reproduces a movie in .mp4 formtat - with both audio and video parts. The TV is a Blueprint and it’s using the MovieTexture, but I don’t know how to handle the sound, there.

Create a MediaSoundWave from the MediaPlayer. You can use that asset just like any other sound node.

Hey ocramot,

I’m not hugely knowledgeable about the media player specifically (gmpreussner is currently the expert) but I can help you with general mixing.

The sound that you are playing with the media player is a USoundWave type which has all the power of other audio, including sound classes and sound mixes.

Unfortunately, the UE4 mix system isn’t well documented (I’m working on getting that documented!) but briefly, the way it works is:

    1. Create a sound class that you want to play your media sound waves with (or any sound wave)
    1. Set whatever
      default volumes you want with the
      sound class
    1. Make sure to add this new sound class as the sound class field of the sound waves you want to affect with it.
    1. Create a sound mix
      (USoundMix) with the volume of
      the sound class you want to set to 0
      in the “sound class adjustment” list
      of the sound mix
    1. When you want to
      mute the mix of the sound classes
      based on gameplay, from BP, use the
      function PushSoundMixModifier and
      pass in the sound mix you want to add
      to the mix.
    1. When you want to remove
      the muting mix, just call
      PopSoundMixModifier with the
      soundmix.

Some cool things about the mix system is that you can have any number of sound mixes at the same and their sound-class adjustments “mix” together in the way you’d expect. You can also have sound mixes trigger automatically based on volume thresholds in a sound class (sort of like a ducking system).

Thank you! I suppose you’re talking about C++ coding, and I’m doing a Bluprints-only project at the (and I’m also a noob at C++ programming in UE4). Anyway I’ll try to implement your solution ASAP

No, this is all BP. PushSoundMixModifier is a BP function, so is PopSoundMixModifier. To create a sound mix, it’s in the sound context menu (like SoundCue, etc). It’s all BP.

Hey MinusKelvin,

I’m also trying to figure out how to adjust/mute the volume of a Media Player. I’m trying to follow your steps above, but have gotten stuck.

I cannot figure out how to do step (3) – how do you add a sound class to a media player? In the graph of the sound class itself there doesn’t seem to be a way to link it up to specific variables (only create an hierarchy of sound classes) and I can’t seem to even bring a sound class as a variable into another blueprint and link it up that way.

So I have a UMG widget that contains my video player. Inside that I have my Media Player, which I am controlling playback for, and within which I want to be able to control the volume. What do I need to do to assign this Media Player a sound class which I can then affect by popping/pushing mix modifiers?

Thanks for any help!

Hey man, a media sound wave generated from the media player (check out Media Framework in Unreal Engine | Unreal Engine 5.1 Documentation if you haven’t) is just a regular USoundBase type, which means that theoretically you can hook up sound classes to it like any USoundBase. If you double click the sound player wave, it does appear like the “sound” group that you can see in most soundwaves is missing. This is probably because originally the programmer who made this wasn’t thinking it would be relevant.

However, ff you drag your sound wave from the content browser to the editor, it will make an ambient sound component automatically for you. In that case, you can just add a sound class override to the ambient actor like in the following screenshot (i just tested media player waves working with the sound class system):

Thanks for your response!

I’m still not quite there though.

I’ve done what you suggested:

  1. Created a Media Sound Wave from the Media Player
  2. Added it to the scene to create and AmbientSound
  3. Created a Sound Class and set the Sound Class into the Sound Class Override section of the AmbientSound details

For testing purposes, I’ve set the Sound Class to make the volume 0. But when I:

  1. Open up the Media Player and play the video (which I am doing through UMG) the volume is still on maximum.

I feel like there’s a step I’m missing to connect the AmbientSound to actually be the sound stream for the Media Player…?

Additionally, I’m just trying to get the AmbientSound to play separately, and that’s not even working. Here’s my setup for that:

Thanks for your help!

Also, from your setup it looks like the right direction if I was planning to have the Media Player as a texture in a 3D scene. I’m ultimately trying to have volume controls on a video player based entirely in the UMG, so I wonder if an AmbientSound will work for that at all?

I’m not sure how media player works through UMG – I’ll have to ping one of the guys who knows media player (or UMG) more than I do.

Hey localstarlight,

There are no volume controls on the MediaPlayer or the MediaSoundWave. You need to control the volume on your sound assets instead. The MediaSoundWave works just like any other SoundWave node and can be used in the Sound Editor.

Sorry, I might have misunderstood. It seems that you’re trying to play the audio in the UI, is that correct?

So, if you’re playing audio from UMG in general, you just need to emulate the way we play audio for UMG with any sound asset. Check out FSlateSoundDevice::PlaySound to see how that’s done. The media sound wave is inherits from the same class as a regular sound wave so you can use it where you would normal sound waves. So, for example, you can create a sound cue, add a wave player node, then drop your media wave in the wave reference entry for the wave player. Then once you have that you can module the audio like you can anything else – for example, you can select the “output” node and change the sound class. Or you can add a manual volume modulator, etc.

All you need to do is play the sound cue before you play the media player. The code for the media sound wave automatically knows what media player it’s associated with and “procedurally generates” the audio for the sound from the playing video. There are currently some issues with sync (especially if the video loops and you drop in and out of PIE) that we are planning on fixing in the future.

Here’s a screenshot of a sound cue that I just tested that uses the media wave instead of a normal wave:

Hey guys,

I’m either doing something really wrong, or I’m facing some kind of bug here. I wasn’t able to upload images here for some reason, so you can download them here: http://we.tl/BvGE7anssD

Trying to follow your instructions:

Created the Media Sound Wave
(Image 1)

Created the Sound Cue
(Image 2)

Added Wave Player to Sound Cue, and simply linked it up to the output
(Image 3)

Then I tried what I assumed would be a simple setup to just test playing the Sound Cue in Blueprint
(Image 4)

But nothing happens, no sound. I thought maybe that setup was wrong, so I went back to the Sound Cue editor and just tried to play the sound in there using the play button
(Image 5)

No sound playing from there either. Perhaps there’s something wrong with the Media Sound Wave itself?

Oddly, I noticed that if I open the Media Player I used to generate the Media Sound Wave, it doesn’t actually list any audio tracks:
(Image 6)

And yet, if I play the Media Player in that editor, it plays fine with sound. And if I play the Media Player in the UMG, it also plays fine with sound. Why would it not list any audio track and yet play with sound? Could this be the source of the problem with why the Sound Cue won’t play?

I’m a bit flummoxed by all this! All I really need to do actually is be able to control the master volume for the entire game with a slider in the UMG. Is there an easier way to do this? I want a single slider that the user can use to control the total volume of everything.
Being able to control the volume for a Media Player would also be useful as well, and I would like to figure out how to do that also.

Thanks for all your help, I’m sure we’ll get there in the end.

If you try to play the media sound wave by itself it won’t generate audio. It creates audio “on the fly” when the media player itself plays. If it’s playing audio when you preview the media file, then it’s definitely working. Unfortunately you wont be able to preview the sound cue on its own with audio without playing the media file.

As for the real issue you’re trying to do: turn down all volume. Luckily all audio is by default using the master sound class. So you can just push a sound mix that sets the master sound class to 0 volume (by using the volume adjuster for the master class in the sound mix).

HOWEVER, until very recently (as in, won’t be available till 4.12 I believe), UE4 didn’t support direct dynamic volume-control of a sound class in a sound mix, which, besides a number of good sound-design use-cases, makes user-preference sliders for audio problematic (without a C++ hack). To fix this, I added a feature for paragon to allow you to override (or add) any sound class volume or pitch adjuster in any sound mix at any from BP.

In the short term, until you get the new dynamic sound-class volume feature, you can approximate a dynamic slider by creating say ~5 sound mixes (or however many you want) that set the master sound class to various levels of volume adjustment and either snap to those in the user-pref slider or just pick the nearest one.

To be more concrete:

  1. Create N number of sound mixes that set a sound-class adjustment of volume for the “master” sound class. For example, they might be named SoundMix_Master_0, SoundMix_Master_25, SoundMix_Master_50, SoundMix_Master_75, SoundMix_Master_100, for 0-volume, 25% volume, 50% volume, 75% volume, and 100% volume. Make the “interpolation” fade- something reasonable like 0.25 seconds or something.

  2. In the UMG code that handles the user-pref slider, find the points in the slider fraction that you want to hook up to the above sound mixes.

  3. Keep track of what the current sound mix is, and “pop” the sound mix when the user switches to a new sound-mix, then push the sound mix that corresponds to the value you want.

Agreed that this is totally not ideal, but it should theoretically work to set all game volume based on a user-pref slider. If you have github access you should be able to get the new feature from this integration to main from our internal dev-framework stream:

https://github.com/EpicGames/UnrealEngine/commit/4c41590c3d19013a848ae5a9ad7f2dcfbf741fb2

"Change 2874623 on 2016/02/19 by Aaron.McLeran

UE-27131 Support for changing sound class volumes dynamically

- new BP function to override a sound mix sound class adjuster
- cleanup of AudioDevice.h and AudioDevice.cpp
   - removing unnecessarily forward declares on various types
   - removing unnecessary spaces and (void) params, etc"

OK, this is starting to make sense.

But when you say “master sound class” are you referring to something that already exists, or a Sound Class I need to create myself and somehow apply to everything?

When I create a Sound Mix, in the Sound Classes → Sound Class Effects → Sound Class section there’s no option to select a ‘master sound class’, only Sound Classes I’ve created myself.

So if it’s the case that I need to create this ‘master sound class’ myself, then I’m still a little confused as to how to apply it to all the many Media Players that I have (over 500). This is what you were trying to help me with originally – which involved dragging Media Waves into the editor to create AmbientSounds, but that seems like the wrong approach for a UMG-based video/audio player.

I completely understand the pop/push approach to volume control using a variety of different Sound Mixes, that shouldn’t be any problem to set up, just still confused about this issue of a master sound class that incorporates everything, and how to link my Media Players into it.

Thanks again for your help.

Hi gmpreussner,
Yes, that’s correct. I would like to be able to adjust the volume of videos playing in the UMG - how can I go about that?