Fix blocked FMOD audio in Browsers

    If you are working on a HTML5/WebGL version of your Unity game, you might have noticed that sounds do not play in Chrome, Firefox and Safari (iOS). These browsers require user interaction to play audio. Chrome for example displays warning messages in the console when trying to play audio:

    AudioContext warnings in Chrome
    AudioContext warnings in Chrome

    The reason for blocking audio from playing is to improve the user experience and to stop websites from auto playing advertisements for example.

    FMOD’s official workaround is to reinitialize the webaudio driver by suspending and resuming the mixer of the FMOD Core System through an user interaction. To implement this functionality you can add a button at the start of your game and call following method when the button is pressed:

       bool audioResumed = false;
    
       public void ResumeAudio()
        {
            if (!audioResumed)
            {
                var result = FMODUnity.RuntimeManager.CoreSystem.mixerSuspend();
                Debug.Log(result);
                result = FMODUnity.RuntimeManager.CoreSystem.mixerResume();
                Debug.Log(result);
                audioResumed = true;
            }
        }

    Check in the console if result returns FMOD.RESULT.OK. The audio in your WebGL build should now work as intended.

    ↑ To the Top