Can't load audio from persistentDataPath with UnityWebRequestMultimedia (404)

Hello,

I have a small WebGL project where I need to download and save multiples (hundreds) small audio files (MP3) from another server into the persistentDataPath, to be used later in the app as AudioClips.

  • download the MP3s from remote server and save audio files in current server with
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/" + filename, webRequest.downloadHandler.data);

Working without issue, and I can see the audio files stored in the IndexedDB.

  • retrieving an audio file from persistentDataPath (IndexedDB) :
System.IO.File.Exists (Application.persistentDataPath + "/" + filename)

return TRUE

and

Byte[] bytes = System.IO.File.ReadAllBytes(Application.persistentDataPath + "/" + filename);
Debug.Log("bytes length : "+bytes.Length);

return right length of the file

So I know that my file can be found at the right place in WebGL IndexedDB.

BUT

UnityWebRequestMultimedia.GetAudioClip(Application.persistentDataPath + "/" + filename, AudioType.MPEG)

will get me a 404 because UnityWebRequest will automaticaly add the scheme and host of the path of the website where my WebGL app is loaded.

So instead of something like that for UnityWebRequest.url :
/idbfs/eeea60de649e89f719d7cb47c998e012/audio.mp3

I have a bad URL like this :
https://mywebsite.com/idbfs/eeea60de649e89f719d7cb47c998e012/audio.mp3

That’s why I get a 404 !

And because of that I don’t know how to get the right URL to retrieve and load the audio files as AudioClip from the persistentDataPath in WebGL (work without issue in Editor, windows Build and Android build).
Or maybe there is a way to get the AudioClip from the raw bytes ?

Any help appreciated ^^ !

Nobody can help about this issue ?

I didn’t found any alternative and really need to load AudioClips from MP3s in persistentDataPath with WebGL !

I try one last message to ask for help about this issue !

Did you find any solution or any alternate way of doing it?i am also trying something similar and am stuck in the same issue

You can preface the path sent to GetAudioClip with “file://” , that way “http://” won’t be prepended.