What platform are you building for?
iOS
What framework are you building with?
Cordova
What is your build ID?
5f0df44c-7952-4c47-90e5-4a5521ec99d8
What is your error message?
Audio Error: Cannot use audio file from resource ‘sonar_short.mp3’, code: 1
Please describe the issue:
I have cordova-plugin-media and cordova-plugin-file installed, and I’m trying to play a media file that’s under www in the project, and I’ve referenced documentation for these plugins as well as asking AI regarding this.
It works fine for Android using “file:///android_asset/www/sonar_short.mp3”
For iOS supposedly both “sonar_short.mp3” and “cdvfile://localhost/www/sonar_short.mp3” should work, but neither does as per the error message:
Audio Error: Cannot use audio file from resource ‘sonar_short.mp3’, code: 1
(MediaError.MEDIA_ERR_ABORTED whatever that means)
The file has been created by Audacity and plays fine in Windows and Android.
I’ve checked the IPA and the file is stored under “\Payload\CliqTags Nearby.app\www”
Update: cordova.file.applicationDirectory + “www/” + filename doesn’t work either. I also tested with 3 different mp3 files, so the likelihood it’s an issue with the files should be small.
Any hint as to what I might be doing wrong here?
Thanks in advance.
Code snippet:
//One time:
path = "cdvfile://localhost/www/sonar_short.mp3";
maxProximityMedia = new Media(path,
function () {
log("maxProximityPlayInit(): Audio Success");
},
function (err) {
log("maxProximityPlayInit(): Audio Error: " + JSON.stringify(err), true);
});
}
...
//Any number of times:
if (volume > 0.0) {
maxProximityMedia.play();
maxProximityMedia.setVolume(volume);
}