1

I can't get the cordova media plugin to work, I get error code 1 which signals that the file is not getting loaded. I've tried a number of variations, but can't figure out which path is correct.

Currently my code looks like this:

function onDeviceMediaReady () {
var path = window.cordova.file.applicationDirectory + 'why.mp3';
    console.log(path);
    narrative = new Media(path, // success callback
        function() {
            console.log("playAudio():Audio Success");
        },

        // error callback
        function(err) {
            console.log("playAudio():Audio Error: "+ err.code);
        });
}

this gives me a path that's file://var/cotainers/Bundle/Application/[GUID]/Cordova400.app/why.mp3

I don't get why I can't find it. the file is in the telerik appbuilder root directory.

Jakob
  • 4,784
  • 8
  • 53
  • 79

2 Answers2

0

Inside your 'WWW' folder place the file inside 'sound' folder & try following

var srcBookmark = "sound/yes.mp3"; //ios 
var iOSPlayOptions = {
    numberOfLoops: 1,
    playAudioWhenScreenIsLocked : false
}
var media = $cordovaMedia.newMedia(srcBookmark);
//media.play(); //android
media.play(iOSPlayOptions); //ios
$timeout(function(){
    media.stop();
    media.release()
}, 500);
0

If you're using appBuilder to test your app te aplication folder is the telerik folder, you must deploy your app as APK and test the folder

BlackSlash
  • 625
  • 5
  • 13