Prevent engine from muting itself when minimized?

I’ve noticed that UE4 will mute all of its audio output when it doesn’t have window focus. This poster found a way to get around this by altering the engine files, but I’d like to be able to change this functionality in a game or plugin, so the packaged executable will have audio when minimized. Is there any way to do this from a project’s code?

The exact line in the engine that is causing this trouble is in FWindowsPlatformMisc::PumpMessages(), which is static and thus cannot be overridden from a custom FWindowsPlatformMisc subclass.

I’ve found a workaround for this problem. What I do is add a line to an FTickableGameObject, in the Tick() function so it’s called constantly. This line is just:

GVolumeMultiplier = 1.0f;

This overrides the engine’s natural functionality, which sets GVolumeMultiplier to 0 if the window doesn’t have focus. It’s not a perfect solution; it may cause problems if other parts of the project try to edit GVolumeMultiplier (maybe like an options menu that adjusts the game volume), but it works for a simple case.

I’ve just recently added a config value to set the unfocused volume in CL#2341022, so you’ll soon be able to add:

[Audio]
UnfocusedVolumeMultiplier=1.0

To your Project’s DefaultEngine.ini file to achieve the same effect without setting the volume multiplier constantly. You’ll know when you’ve got this update because I removed GVolumeMultiplier at the same time.

Great! That sounds very helpful.

Thanks, adding this to DefaultEngine.ini worked for me:
[Audio]
UnfocusedVolumeMultiplier=1.0