I'm working on a simple app that has but a few functions, that is supposed to play audio ether from a web site ie.
function playfile(){
var playing = "http://static.weareswoop.com/audio/charlestown/track_1.mp3";
var my_media = new Media(playing,
function() {
alert("playAudio():Audio Success");
},
function(err) {
if(err.message != undefined) { alert("playAudio():Audio Error: "+err.message); }
if(err.code != undefined) { alert("playAudio():Audio Error: "+err.code); }
});
// Play audio
my_media.play();
}
with the html of
<a href="#" onclick="playfile()">play</a>
No matter what I do this does not work on Andriod (version 2.X and 4.X), but does work just fine on iOS (v5 iPad 1 tested).
If I do this against a web based file, I get no response from either the Success or Failure functions, but if I run this agains a local file on the SD car i.e. file:///mnt/sd-card/mining/charlestown/track1.mp3 I get error code 1 without an error message.
Any help would be more than welcomed.
edit: to get the local file version which I am using FileTransfer() download (which works just fine on any OS).
window.appRootDirName = "mining"; // sets the working directory
var playing = window.appRootDir.fullPath + "/track1.mp3"; // sets filename
Thus I end up with a URI file:///mnt/sd-card/mining/track1.mp3 which is the exact correct uri when working on 2.x Samsung Galaxy Y.
Again, I must stress, this entire situation works on iOS, but not on Android. On Android when getting a HTTP: based file it gives no error or success, on FILE:// it gives error code 1 when trying to play.