I want for my game to allow the player to play their own mp3 in the background while playing. I read that in the past it was done with the www class, which is now deprecated. We should use instead UnityWebRequestMultimedia.GetAudioClip Unity - Scripting API: Networking.UnityWebRequestMultimedia.GetAudioClip
However, the example there is for a web-hosted audio file and not for a local file on the Android system and I have 2 unknowns on how to change it to fit my needs:
would the “yield returnwww.Send();” in the coroutine work for a local file path?
My use case is that the user would have to choose a file from their own Android file system. However, before building that functionality (by tweaking that asset https://assetstore.unity.com/packages/tools/input-management/file-selection-dialogue-11374) I want to test it with a given string for the file path. I don’t know how the file path in Android should look like though, i.e. how is the Android root folder referenced from within Unity?
the application has to have reading rights for given file first of all, I have no idea what the asset you linked does, but it should return path to the file - if not, you have to find workaround with that asset
you can reference the file by its normal filesystem path, e.g. something like “/sdcard/media/music/file.mp3” would work with webrequest with file:// protocol
Thanks, so the root folder for the sdcard should be “sdcard” and the uri for the SD card should be “file://sdcard/…”? What would the be for the built-in memory then? Or is it specific to the android device?