Publish webgl using network audio error message JS_Sound_GetLoadState

Using UnityWebRequestMultimedia GetAudioClip retrieves network audio and runs normally in the editor, but when published to webgl and opened using Chrome browser, an error message appears。

The Unity version used is 2021.3.0f1

Error Message:
An error occurred running the Unity content on this page. Seeyour browser JavaScript console for more info. The error was:TypeError: Cannot read properties of undefined (reading 'error)at Js Sound GetLoadState (blob:http://127.0.0.1:8080/48b0013a-6f7b-4ed4-8e83ca2a9cf09756:3 46483)at wasm://wasm/06479

IEnumerator PlayAudioClip(string audioUrl,Action<AudioClip> callback)
        {
            using UnityWebRequest audioRequest = UnityWebRequestMultimedia.GetAudioClip(audioUrl, AudioType.WAV);
            yield return audioRequest.SendWebRequest();

            if (audioRequest.result != UnityWebRequest.Result.Success)
            {
                Debug.Log("Failed to load audio: " + audioRequest.error);
            }
            else
            {
                AudioClip audioClip = DownloadHandlerAudioClip.GetContent(audioRequest);
                callback(audioClip);
            }
        }

9495493--1337050--upload_2023-11-27_21-29-42.png

What is the format of the audio element you are retrieving? do it behave differently if you change that type?

Also, based on your code the error could be happening in the callback. Would it be possible to expand what is going on in there?

Thanks!

  1. I have tried both MPEG and WAV audio formats and they perform consistently

  2. The callback did not have any errors, but in the editor clip.length is normal length, but in the webgl length is 0