MP3 Streaming Assets won't load on iOS using UnityWebRequestMultimedia

Hi there!

So basically, I got some mp3 as streaming assets in the “StreamingAssets” folder of the application. The files are always local. I can retrieve them and play them on WebGL and Android builds with UnityWebRequestMultimedia using that code:

DownloadHandlerAudioClip dHA = new DownloadHandlerAudioClip(path, AudioType.MPEG);
            dHA.streamAudio = false;  // You can set this to true if you want to stream
            www.downloadHandler = dHA;
            www.timeout = 10;

            // Send the request and wait for it to complete
            yield return www.SendWebRequest();

            if (www.responseCode != 200 || www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
            {
                Debug.LogError($"Error loading audio clip: {www.error}, Response Code: {www.responseCode}");
            }
            else
            {
                Debug.LogWarning($"Succed loading audio clip: {www.error}, Response Code: {www.responseCode}");
                AudioClip currentAudioClip = DownloadHandlerAudioClip.GetContent(www);
            }

on iOS I can validate that the files are accessible:

audioClipPath = Application.dataPath + "/Raw/Voices/" + LocalizationManager.CurrentLanguageCode + "/" + key + ".mp3";

if (System.IO.File.Exists(audioClipPath))
{
    Debug.Log("File exists");
}

I can’t use the UnityWebRequest as it returns 0 with the correct path. I did try a lot of various paths just in case but never seems to have found something that works.

In the documentation it doesn’t say what I could use to play the mp3 files in this case Unity - Manual: Streaming Assets (unity3d.com) as the UnityWebRequest solution is required only for WebGL and Android.

That leaves me with only one solution, reading the file as Byte and using another dll library to decode the mp3 file to play it inside Unity. I found another post here:
Anyone been able to load an audio file from local filesystem on iOS and playback a clip? - Questions & Answers - Unity Discussions

I just wonder if I have tested this correctly and if there is not a simpler solution using UnityWebRequest.
Anyone ?

Here’s my handy-dandy StreamingAssets cribsheet:

Disclaimer 1: haven’t streamed a “StreamingAssets” asset in a few years, probably since Unity2021 or so.

Disclaimer 2: have never tried decompressing an MP3 using the handler you list above; You might be getting an error in the device log if (for instance) some nuance of the MP3 you chose isn’t supported.

UnityWebRequest takes URI as parameter, not file path. The simplest way of making it work on all platforms is to do
new System.Uri(filePath)
and pass that directly to UnityWebRequest (it accepts Uri objects besides strings).

Thanks! This is the way :).
I have been looking for a solution for quite some time. I left feedback on the official documentation of Unity. This could be helpful to other, I guess.