I am using cordova-plugin-nativeaudio to play audio in the application. When I am trying to preload a file with iOS device:
preload('testsound', cordova.file.dataDirectory + "audio/0/Hello.mp3");
I am getting an error of:
ERROR: Unhandled Promise rejection: (NATIVE AUDIO) Asset not found. (file:///var/mobile/Containers/Data/Application/"[GUID]/Library/NoCloud/audio/0/Hello.mp3) ; Zone: ; Task: setTimeout ; Value: (NATIVE AUDIO) Asset not found. (file:///var/mobile/Containers/Data/Application/[GUID]/Library/NoCloud/audio/0/Hello.mp3)
The target file
The target file (audio/0/Hello.mp3) is downloaded from external url and stored in cordova.file.dataDirectory. It is downloaded successfully as following console output:
download complete: file:///var/mobile/Containers/Data/Application/[GUID]/Library/NoCloud/audio/0/Hello.mp3
To make sure it is really stored in the intended location, I checked:
this.file.checkFile(cordova.file.dataDirectory, "audio/0/Hello.mp3")
Console output shows it is stored successfully:
file:///var/mobile/Containers/Data/Application/[GUID]/Library/NoCloud/audio/0/Hello.mp3 file does EXIST!
Now I tried to preload the file with native audio, I get the error above (the first error in this question).
Problem seems to be where the file is stored
I also tried preload from local applicationDirectory (/www/assets/audio/0/Hello.mp3), preload worked fine. However applicationDirectory is readonly directory, so I cannot download audios from external url and save them there.
Native audio should supports preload from url (not only from local applicationDirectory) since it is stated in their Ionic API doc.
I am getting same error with both emulator and iOS device.
Have anyone experienced a same issue, and managed to sort it out?
Thanks for your help. BR/