File in StreamingAssets won't play with programmer sound on quest 2, works in Editor

So, i followed this example and it works in Unity Editor. However, when I build it on Quest 2, it doesn’t play any sound.

I managed sucesfully to play events from bank, but in this case I need to play file from StreamingAssets.

I created empty project and try to make it work, but with no luck.

Callbacks are fired for CREATED, STARTING, CREATE_PROGRAMMER_SOUND , STARTED, DESTROY_PROGRAMMER_SOUND, STOPPED and DESTROYED, yet no sound is playing.

In logcat I get lot of these errrors:

Error DeviceConfig getProperties failed: Permission denial: reading from settings requires:android.permission.READ_DEVICE_CONFIG

Not sure if it is related and it seems app can’t get that permission, at least not in runtime.

Anyone had similar problem?

I am on Unity 2021.3.40f1 and FMOD 2.02.

I enabled Info logging and now I have more errors in logcat.
Seems so file is somehow not found…

Hi,

Thank you for the logs.

Unfortunately, accessing the StreamingAssets folder is not a simple operation on Android:

Accessing streaming assets
On Android and WebGL platforms, it’s not possible to access the streaming asset files directly via file system APIs and streamingAssets path because these platforms return a URL. Use the UnityWebRequest class to access the content instead.

Unity Documentation. They provide documentation using UnityWebRequest here: UnityWebRequest.

1 Like

Hey, tnx a lot for fast reply, I missed that somehow. I didn’t figure out right away how to allocate and deallocate those downloaded bytes but I made in-memory copy of it like this:

var data = request.downloadHandler.data;
IntPtr unmanagedPointer = Marshal.AllocHGlobal(data.Length);
Marshal.Copy(data, 0, unmanagedPointer, data.Length);
var eventInstance = RuntimeManager.CreateInstance(eventName);
eventInstance.setUserData(unmanagedPointer);
EVENT_CALLBACK clb = new EVENT_CALLBACK(PlaybackEventCallback);
eventInstance.setCallback(clb);

and later dealocatted it like this

Marshal.FreeHGlobal(parameterPtr);

In case someone have similar issue.

1 Like

Thank you for sharing your solution!

1 Like