Error running Fmod in WebGL-build from Unity

Hi everyone.

I am working on a game that has to be played in a browser, and of course I want to use Fmod for sound. However I have been getting an error which means that I can’t trigger my sounds. Take note that this is a development build, and I get no big red errors as these (aswell as no sound) in a regular build. This is the SystemNotInitializedException errors I am getting when I open the second scene:

The application consists of two scenes: the first which just functions to enable audio in the browser by pressing a button and also loads the next scene (not sure if this is necessary), and the main scene where the sound is to be played. I trigger a sound using a key – but only if the bank has been loaded. I have implemented the following code in the start function of my sound script, where I create an instance of my sound:

    if (FMODUnity.RuntimeManager.HasBankLoaded("Master"))
    {
        Debug.Log("Master Bank Loaded");
        eventInstance = FMODUnity.RuntimeManager.CreateInstance(eventPath);
    }

This if-statement was the solution to another problem I had, where the event could not be found. I have no idea if the two issues are related?

The weird thing is, that I could have sworn that I tested Fmod and Unity in the browser, without it causing any problems – but now it obviously does.

I hope anyone has some wise words to share! :slight_smile:

Thanks.

Here are the errors from the console running live in the build in the browser:

hi,

Do you get the same error if you don’t build a Development build ?

Hi!

I get no errors but the same problem of not being able to play sound persists.

Do you wait for the bank to load in the first scene before loading the second scene ?

do you have a call to eventInstance.start() somewhere ?

I’ve also have had problems with Chrome blocking audio when testing locally, Firefox was ok and it was ok when i uploaded to itch.io.

1 Like

Alright. So I’ve come up with a solution that seems to have fixed the issue – for now at least! :wink:
For anyone that have been struggling with the same problem, here’s what I did:

In my loading scene, I manually load the Fmod banks in the awake function. A button in the loading scene starts the next scene, but only if the banks are loaded. I have disabled Fmod’s automatic loading of banks in the Fmod settings in Unity under Initialization. I then build and run, and use Firefox as my default browser.

The problem might have had something to do with the order in which banks are loaded when I build the game for WebGL – but I am not sure… Anyway, now I can go back to designing sounds!!

Thanks for your help chughes42!

Glad you got it working, I came across chrome blocking the audio from starting unless you have interacted with the page before your audio starts.I have music playing as soon as the scene starts so in the first scene I have a loop to check the bank is loaded before loading the scene with the music.