I am using Webworks for Blackberry 10 and using cordova too.
When doing this, the mp3 is played:
var url = "http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3";
var my_media = new Media(url,
// success callback
function () {
console.log("playAudio():Audio Success");
},
// error callback
function (err) {
console.log("playAudio():Audio Error: " + err);
}
);
// Play audio
my_media.play();
(If you can explain me why it does not go to the success callback, it will be nice. :-))
But if I do this:
var url = "local.mp3";
var my_media = new Media(url,
// success callback
function () {
console.log("playAudio():Audio Success");
},
// error callback
function (err) {
console.log("playAudio():Audio Error: " + err);
}
);
// Play audio
my_media.play();
Nothing is played! No error, no nothing. I read that I need to specify a local directory. I then tried "cordova.file.applicationDirectory + "www/sounds/local.mp3", but for some reason, the applicatioDirectory gives me "undefined"!
I also saw this site, but don't know what to put for Blackberry path and iOS.
Any clue why? How can I fix that?
Big thanks in advance guys!
If your audio file is
www/audio/audilofile.mp3, then the url should be:Alternatively, you can get the full path using the IO Plugin:
Take a look also at http://developer.blackberry.com/native/documentation/device_platform/data_access/file_system.html for understanding the directory structure of BlackBerry apps.
I also don't know why the callbacks don't get called. This is what I was searching for when I found this question.