- Home /
How to play local audio clips in webgl
My app records audio and stores it in local filesystem as wav file:
var filepath = Path.Combine(Application.persistentDataPath, filename);
var fileStream = new FileStream(filepath, FileMode.Create);
The app also plays locally stored audio files by loading them via www class:
string urlstr = System.Uri.EscapeUriString("file:" + fileName);
WWW www = new WWW(urlstr);
How can I play locally stored audio clips in webgl builds? I have tried with various uri strings starting with 'file', 'https' etc. but I only get errors like:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED
Failed to load file://idbfs/70490311fe7c84acda8886406a6d884b/Guest_1.wav: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
GET http://localhost/idbfs/70490311fe7c84acda8886406a6d884b/Guest_1.wav net::ERR_CONNECTION_REFUSED
I would like to use GetAudioClip() of www class instead of parsing the data out of wav file and 'manually' constructing the audio clip. (I assume that file apis would work better with idbfs)
Your answer
![](https://koobas.hobune.stream/wayback/20220612140608im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cant load texture by WWW in WebGL 0 Answers
How to use external audioclips from the Android Music folder? 1 Answer
How to send a string from a website to the webGL game 0 Answers
Download multiple files from server 2 Answers
Unity 5.1 WebGL WWW timeout 0 Answers