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);
}
}