question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebGL builds have no audio

See original GitHub issue

Bug description

When building my project on version 2019.4.10f1, the final WebGL build does not play any audio. Can also see some NULL reference exceptions in the browser console when PlayOneShot was called. The audio works when built locally on windows 10.

How to reproduce

  • Using the code snippet below to create a WebGL build.
  • Hosting the build through github pages
  • Testing the build and hearing no audio

- name: Unity - Builder uses: game-ci/unity-builder@v2.0-alpha-6 with: allowDirtyBuild: true projectPath: Phong/ unityVersion: 2019.4.10f1 targetPlatform: WebGL buildsPath: . buildName: WebBuild

Expected behavior

Audio should play in main menu on awake as well as in-game.

Additional details

I did also try Unity versions 2019.3.8f1 and 2019.4.12f1 as well as ubuntu-18.04 and 16.04

Similar issue found on Unity’s issue tracker (has been resolved): https://issuetracker.unity3d.com/issues/audio-no-longer-plays-in-build

Another thread with a similar description: https://forum.unity.com/threads/no-sound-clips-in-webgl-build.1016086/

Null reference exceptions: image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
zmayscommented, Mar 2, 2021

Personally I had to make my own dockerfile to get audio to work:

FROM unityci/editor:ubuntu-2020.1.13f1-webgl-0.10.0

RUN apt-get update && apt-get install ffmpeg -y

You can reference your own dockerfile in the action yml:

      - name: build
        id: build
        uses: game-ci/unity-builder@v2.0-alpha-6
        with:
          projectPath: ${{ matrix.projectPath }}
          unityVersion: ${{ matrix.unityVersion }}
          targetPlatform: ${{ matrix.targetPlatform }}
          versioning: Semantic
          customImage: 'zmays/unity-editor:latest'
2reactions
zmayscommented, Mar 3, 2021

yup @webbertakken no-recommends worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

No Sound in WebGL build - Unity Forum
Only my games have no sound, on both itch.io and simmer.io, seems like build don't contain audio for some reason. Other games on...
Read more >
No sound in Unity WebGL build - FMOD Forums
Hi, I managed to create a HTML5 WebGL build of my Unity project using FMOD and everything works fine when I load it...
Read more >
Problems with audio not launching in webgl build - Ask
I'm relatively sure that the issue is not here but where the code tries to access the AudioSource. Or the problem is just...
Read more >
No sounds playing in webgl build - Questions & Support - itch.io
The music and sfx works fine in Unity, but whenever I put them on itch, they're completely silent. The background music for my...
Read more >
[WebGL] Audio is not played when in built Player - Issue Tracker
1. Open the attached project Scene labeled "SampleScene" · 2. Enter the Play Mode · 3. Observe that the audio is played ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found