Search Unity

Audio not playing in WebGL

Discussion in 'Web' started by monark, Jan 19, 2016.

  1. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    According to this http://docs.unity3d.com/Manual/webgl-audio.html www.audioClip works in webgl.

    But when I try and load a .mp3 from the server it loads up fine but I get no audio coming out when I play it.

    If I try and use .ogg format instead it tells me Chrome can't stream that format even though I have streaming turned off.

    Can anyone confirm if loading .mp3 files using www.audioClip actually works in WebGL?

    Currently building with Unity5.3.1f1
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    how are you loading the mp3 ?

    You should build it into an asset bundle, which then you download at run-time from the server.
     
  3. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Oh right that's a pain I have about 1000 clips, and I load them as required, I don't want to load them all at once. Currently all built using ffmpeg.
    Which works fine for the Webplayer.
     
  4. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Ah wait it is playing, just at a very very low volume...

    If I crank the volume up to 100% on my laptop I can hear it fine, I just get deafened by the Windows alerts ;)

    I'll have to see if I can control the volume dependent on platform.
     
  5. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    In a quick test in Firefox and Chrome I would say the volume is about 1/10th that of the webplayer by default. Further testing required. At least it is playing...
    It's not a direct comparison as the webplayer version was built in 4.3 and the WebGl one is 5.3 so I'm not sure what else might have changed.
     
    Last edited: Jan 19, 2016
  6. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    I think I'll put together a mini test case and post a bug from that tomorrow.
     
  7. lloydsummers

    lloydsummers

    Joined:
    May 17, 2013
    Posts:
    359
    In case it helps, I use audio with WebGL using AudioClips for my demos.

    Works fine, volume is normal, using 5.3.1f1.
     
  8. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Hmm a small test case has it working here too....