Search Unity

WebGL Sound Problems

Discussion in 'Web' started by Zyrathius, Aug 6, 2019.

  1. Zyrathius

    Zyrathius

    Joined:
    Dec 18, 2012
    Posts:
    20
    I've been fighting some sound issues with my WebGL build for the past few days to no avail. The sound works in the editor, works in the browser when ran in Firefox locally, however when zipped and ran from our hosted site via a learning management system, the sound does not work. I have tried via Chrome and Firefox both.

    I have tried using AAC, WAV, MP3 and OGG files. The first three produce browser errors. The OGG does not error out but also does not make any sound. Incidentally the OGG doesn't work when ran locally..

    My relevant code is...

    Code (CSharp):
    1. public IEnumerator LoadSound(string loadSound)
    2.     {
    3.         path = Application.streamingAssetsPath + "/Lessons/Sounds/";
    4.  
    5.         //Download
    6.         using (UnityWebRequest loadedSound = UnityWebRequestMultimedia.GetAudioClip(path + loadSound + ".aac", AudioType.ACC))
    7.         {
    8.             // Wait for import to complete
    9.             yield return loadedSound.SendWebRequest();
    10.  
    11.             if (loadedSound.isDone)
    12.             {
    13.                 returnSound = DownloadHandlerAudioClip.GetContent(loadedSound);
    14.             }
    15.  
    16.             audioSource.clip = returnSound;
    17.             audioSource.Play();
    18.         }
    19.     }
    The audioSource is a public variable that I drug the reference into the component to establish. The path I know works because I have another function almost identical to this one that loads images and there are no problems with the image portion of my application.

    Only other odd bit is that I'm loading the sounds via the streamingassets folder externally at runtime. I'm doing this exact thing with the images as well, which works for those.

    If anyone has any ideas, I'd really appreciate them

    Also, I am calling this code from a button activated by the user, so when they click it, it loads and is supposed to play the audio clip.
     
  2. Logic_Bomb

    Logic_Bomb

    Joined:
    Apr 6, 2017
    Posts:
    16
    If it works in firefox locally, then the issue is with your LMS. There's not enough info here to know for sure but if I had to guess I'd say you need to whitelist the audio file mime types on the server. You can check if they are being blocked on download with a browser addon like firebug. Good luck!
     
  3. Zyrathius

    Zyrathius

    Joined:
    Dec 18, 2012
    Posts:
    20
    Thanks for the reply, I will dig into audio types as soon as I can back to that issue! I tried asking SABA but they passed it off as something else.
     
  4. Zyrathius

    Zyrathius

    Joined:
    Dec 18, 2012
    Posts:
    20
    What a headache. Haha

    Development Build with Exceptions enabled gives me this from the web console...

    exception thrown: TypeError: sound is undefined,_JS_Sound_GetLoadState@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286:3212:6
    __ZN4FMOD5Sound12getOpenStateEP14FMOD_OPENSTATEPjPbS4_@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[3332]:0x1b0293
    __ZN11SoundHandle8Instance15UpdateLoadStateEv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[3295]:0x1ac953
    __ZN12SoundManager6UpdateEv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[3287]:0x1ab7c0
    __ZN11AudioModule6UpdateEv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[3879]:0x1dcf52
    __ZZL31InitializeAudioManagerCallbacksvEN36PostLateUpdateUpdateAudioRegistrator7ForwardEv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[3874]:0x1dce64
    __Z17ExecutePlayerLoopP22NativePlayerLoopSystem@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[10403]:0x40941c
    __Z17ExecutePlayerLoopP22NativePlayerLoopSystem@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[10403]:0x409431
    __Z10PlayerLoopv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[10397]:0x408702
    __ZL8MainLoopv@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[10383]:0x406a11
    dynCall_v@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286 line 1149 > WebAssembly.instantiate:wasm-function[83417]:0x175929c
    UnityLoader["1c9793064a4618150a46e7fc5945a82c"]/Module.dynCall_v@blob:https://sabacloud.com/ae91220d-795e-477f-b356-5abc37cab286:27683:36
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Print to log the path, and check if it's valid path...