Hello,
I’m struggling to get my just downloaded local mp3 file to play on my Android, it works fine on my Windows Unity development computer.
My app:
- Downloads and plays an MP3 from my dropbox location
- It then saves the Mp3 to the Application.persistentDataPath
- Next time playing it is selected in the app, it attempts to play the mp3 from the saved mp3 file
- this works fine under Windows
- but on Android, the app won’t play the mp3.
- I find the saved file on the Android outside of my app and can play it fine…which tells me it downloaded successfully
To give permissions to the app, I’ve done this
if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead)) {
Permission.RequestUserPermission(Permission.ExternalStorageRead);
}
…and can confirm at runtime that the above is successful
and this in the manifest;
…and this:
android:usesCleartextTraffic=“true”
The code segment:
(audioType is MPEG)
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(fullPath, audioType)) {
yield return www.SendWebRequest();
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
I’ve looked thru dozens of potential solutions online and no luck.
Questions:
- Can we play local Mp3 files from the Application.persistentDataPath on Android
- if so, any ideas of what I’m missing?
- If not, is it that we still have to convert the Mp3 to a WAV file in order to play the on Android? Or?
Thanks in advance,
Kevin