Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question Audio not working on WebGL builds in any browser

Discussion in 'Audio & Video' started by GrayRabbitGames, Jan 28, 2021.

  1. GrayRabbitGames

    GrayRabbitGames

    Joined:
    Mar 1, 2016
    Posts:
    6
    I'm working on a game for Global GameJam 2021. It's been a long time since I made a WebGL build but this seems the easiest way to share my work.

    The problem is, I cannot get the game's audio to work on any webGL build, on any browser. I've tried running it locally, and also sharing to Play.Unity.Com (here), in Chrome and also Firefox.

    I can hear the sound just fine when I play the game in editor, but not when the game is built. I don't see any audio-related errors in the browser console.

    I've been searching all over the web for answers - I can see that some browsers were having issues playing audio on Unity WebGL, especially if the player hadn't interacted with the page first, but that is definitely not a problem on Play.Unity.Com, which makes you press several buttons before the game starts.

    The sounds are all .WAV files, and they are being played via simple audiosource calls to Play() or .PlayOneShot().

    Does anyone know what could be causing this? Is there something I'm missing?
     
  2. DrShimizu

    DrShimizu

    Joined:
    Apr 13, 2011
    Posts:
    30
    audio works for me. maybe you forgot to unmute. There is a mute button under the player.
     
  3. GrayRabbitGames

    GrayRabbitGames

    Joined:
    Mar 1, 2016
    Posts:
    6
    Thank you for checking! I solved the issue. It turned out that Unity had a bug where audio wouldn't work for WebGL builds on the very specific version of Unity that I was using. I upgraded to a newer version and it fixed the issue.
     
  4. nema007

    nema007

    Joined:
    Jun 4, 2022
    Posts:
    1
    hey , I am facing the same problem , which version was you using to get the bug ?
     
  5. Emilio_LC

    Emilio_LC

    Joined:
    Nov 12, 2023
    Posts:
    7
    From Unity's manual:

    "Because Unity uses FMOD
    to manage audio for platforms, Unity WebGL supports limited audio functionality, which only includes the basic features. FMOD relies on threads, which WebGL doesn’t support. For this reason, Unity uses an implementation based on the internal Web Audio API, which enables the browser to handle audio playback and mixing."

    https://docs.unity3d.com/Manual/webgl-audio.html
     
    SeventhString likes this.