Reputation: 101
I'm developing an app with angularJS and Cordova
Now I'm using the Media Plugin for play different audios
I detected and issue on iOs when I'm playing a background audio (long audio and looped) and another audio(short and plays only one time), when the second audio is finished, then my background audio also stops
any idea how to fix?
piece of code
backgroundMusic = new Media("background",
function () {
//success (object has completed the current play, record, or stop)
},
function (err) {
//error
console.log("playAudio():Audio Error: " + err);
},
function (status) {
if(status == Media.MEDIA_STOPPED){
//patch for ios issue
backgroundMusic.seekTo(1);
backgroundMusic._position = 0;
//end of patch
backgroundMusic.play({playAudioWhenScreenIsLocked : false});
}
}
);
backgroundMusic.play({playAudioWhenScreenIsLocked : false});
//and the other audio
openPopUp = new Media("openPopUp.mp3",
function () {
//success (object has completed the current play, record, or stop)
},
function (err) {
//error
console.log("playAudio():Audio Error: " + err);
}
);
openPopUp.play({playAudioWhenScreenIsLocked : false});
When the openPopUp audio is finished, then the background audio ends too
Upvotes: 0
Views: 1440
Reputation: 11693
a PR has been made for this problem: "Fix CDVSound killing all audio when a single file finishes".
I test it and it fixes the issue. As Apache has no yet merge the PR, I had to fork the repo, include the fix and publish my own version. If you want to try it, replace the original cordova plugin with:
cordova add [email protected]
Upvotes: 1