Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Using $cordovaMedia to play local mp3 in android

$
0
0

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
./platforms/android/assets/www/sounds/blop.mp3
./platforms/android/build/intermediates/assets/armv7/debug/www/sounds/blop.mp3
./platforms/android/build/intermediates/assets/armv7/release/www/sounds/blop.mp3
./platforms/android/build/intermediates/assets/x86/debug/www/sounds/blop.mp3
./platforms/android/build/intermediates/assets/x86/release/www/sounds/blop.mp3
./platforms/android/build/intermediates/res/armv7/debug/raw/blop.mp3
./platforms/android/build/intermediates/res/armv7/release/raw/blop.mp3
./platforms/android/build/intermediates/res/x86/debug/raw/blop.mp3
./platforms/android/build/intermediates/res/x86/release/raw/blop.mp3
./platforms/android/res/raw/blop.mp3
./platforms/ios/build/emulator/zmNinja.app/www/sounds/blop.mp3
./platforms/ios/www/sounds/blop.mp3
./www/sounds/blop.mp3

Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>