I'm trying to play an audio file from online source with this code and build with adobe air and test on iOS 7 iPad but it keeps throwing "cannot use audio file from resource 'http://85.25.95.231/music/H/Hava/[one]/Khoobe Man.mp3', code: 1"
media = new Media('http:\/\/85.25.95.231\/music\/H\/Hava\/[one]\/Khoobe Man.mp3', function(e) {
console.log('succes');
}, function(e) {
console.log('error: ', e);
});
media.play();
I also changed url to 'http://www.getsongg.com/music/H/Hava/[one]/Khoobe Man.mp3' and it doesn't work.
I checked both urls in web and they are OK. (audio plays in Android build)
phonegap: 3.6.3
org.apache.cordova.media: 0.2.13
I changed url to www.w3schools.com/html/horse.mp3
and works on iOS, so I realized there is problem in my url, I've changed all space chars to %20 and everything song is playing!
like this:
http:\/\/85.25.95.231\/music48\/M\/Mahan%20Moein\/[one]\/Salam.mp3
The best way for encoding urls is using js function "encodeURIComponent()", like this:
encodeURIComponent("http:\/\/85.25.95.231\/music48\/M\/Mahan Moein\/[one]\/Salam.mp3")