I search a lot about my problem and I found no solution. In my app using Cordova, I play mp3 sounds. Everything is fine except when you played background music (mp3s, google music, ...), the sound stop the background music. I would like to not stop the background music when my sound is played.
I tried 3 differents methods:
1 - Plugin: cordova-plugin-media
When the sound play, the background music stops and do not restart at the end.
2 - Plugin: cordova-plugin-nativeaudio
Worst, the background music stops when I launch my application
3 - Using javascript function
var mySound = new Audio('sounds/entering.mp3');
mySound.play();
Works fine on Android, the sound is playing, the background music volume decrease and after the sound is finished, the volume of the background music come back to normal. On iOS, the background music stops and do not replay at the end.
Does anyone already had this problem?
Thanks!
I created a cordova plugin to handle this situation: https://github.com/davidfig/cordova-allow-background-audio
cordova add plugin cordova-allow-background-audio
The plugin was based on answers I found here: iphone app allow background music to continue to play
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With