- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
iscf · Jun 03, 2020 at 03:01 PM ·
audiobugwebglbuild-errorstreamingassets
UnityWebRequestMultimedia.GetAudioClip dont't work in WebGL build (2019.3.15f1).
Hello everyone,
I tried to use the sample of code here to request an audio file in WebGL build (in 2019.3.15f1).
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequestMultimedia.GetAudioClip.html
But only Wav files work, and Mp3 or OGG fail to load. I have read the limitation on my browser (Firefox) and normaly it support all this formats, but i alwais get
Streaming of 'ogg' on this platform is not supported.
Or mpeg.
How can I read compressed audio from SteamingAssets Folder ? Thanks in advance.
Here the code i use:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class AudioRequest
{
public AudioClip audioClip = null;
public IEnumerator SendGetAudio(string url)
{
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.WAV))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
throw new Exception(www.error + "\n" + url);
}
else
{
audioClip = DownloadHandlerAudioClip.GetContent(www);
}
}
}
}
Comment