Hello, I have the following code to play a local mp3 file in iOS and Android.
This works fine in iOS but not in android. What am I missing?
var mediasrc = $ionicPlatform.is('ios') ? "sounds/blop.mp3":"/android_asset/www/sounds/blop.mp3";
media = $cordovaMedia.newMedia(mediasrc);
// and then much later, when I receive a push notification
// I do a media.play() if mode is foreground
Here are my locations for blop.mp3 after ionic build android and ionic build iOS
$ find . -name blop.mp3
Okay, I fixed it - also, I forked a version that disables all the crazy android permissions the default version needs just to play a media file - no additional permissions are needed if all you want to do is play a small media file while in foreground, which was my need
How did you resolve this bug? I am struggling with the same issue.
I don’t remember what I did differently, but my code is open:
How I defined the media path:
console.log (">>>>>>>>>>>>>>>>>EVENT SERVER SENDING: type="+type+" DATA="+JSON.stringify(obj));
/*if (ws.$status() == ws.$CLOSED)
NVRDataModel.log("Websocket was closed, trying to re-open");
//ws.$on ('$open', openHandshake);
ws.$on('$open', openHandshake, function()
//console.log(" sending " + type + " " +
How I play local media:
Copying media to the right place before build:
# exe cp www/external/GCMIntentService.java platforms/android/src/com/adobe/phonegap/push
# echo "Directory plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/ does not exist, skipping..."
echo "Copying custom sound"
if [ -d "platforms/android" ]; then
exe mkdir -p platforms/android/res/raw/
exe cp www/sounds/blop.mp3 platforms/android/res/raw/
exe cp www/sounds/blop.caf platforms/ios/zmNinja/Resources
echo "Directory platforms/android does not exist, skipping..."
#echo "Copying plist hack for iOS for non SSL connections"
#if [ -d "platforms/ios/zmNinja" ]; then
# exe cp www/external/zmNinja-Info.plist.IOS9nonSSLPatch platforms/ios/zmNinja/zmNinja-Info.plist
yeah I cant get it to work on ios at all. Does yours work on IOS?
yup. I thought you said you had the same problem I had (which was works on iOS not android)
The code I pointed you to also has blocks for ios.