@arielf Yes that does work
In fact, here is my updated code to allow it to work properly. There is a toInternalURL() function you can use to accomplish that behavior:
scope.playAudio = function() {
document.addEventListener('deviceready', function () {
var src = cordova.file.dataDirectory + fileSrc;
$window.resolveLocalFileSystemURL(src, function(dir){
basePath = dir.toInternalURL();
media = $cordovaMedia.newMedia(basePath);
var iOSPlayOptions = {
numberOfLoops: 1,
playAudioWhenScreenIsLocked : true
};
$scope.data.playing = true;
media.play(iOSPlayOptions); // iOS only!
//media.play(); // Android
})
});
}
With this in mind, though…have you been able to get mp3 files working with the native HTML 5 audio player? Even when I try to set the the src like in the following, it doesn’t play, even though I know the file exists on the device:
<audio controls>
<source src="cdvfile://localhost/library-nosync/resources/resource-1/resource-1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
A similar thing happens when trying to do the same with video in the HTML 5 video tag