I have an app built in Edge Animate and packaged with PhoneGap Build.
The app itself works fine but, when I use the Home or Back button on an Android device to exit the app, the audio continues to play even though the app itself appears to suspend and go into the background. This is not the case for the iOS version.
Is there a way to mute or pause my audio on those button presses?
I have tried using;
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
function onPause() {
my_MUSIC.pause();
};
function onResume() {
my_MUSIC.play();
};
in both my .html and in my edgeActions.js with no success.
I have even tried using;
<preference name="KeepRunning" value="false"/>
in my config.xml, still keeps running.
I have run out of ideas and can't find any answers on the internet.
Thanks for your help
I have it working...
function loopMUSIC(url) {
// Play the audio file at url
my_MUSIC = new Media(url,
// success callback
function () {},
// error callback
function (err) {},
//Loop audio
function (status){
if (status === Media.MEDIA_STOPPED){
my_MUSIC.play();
}
});
my_MUSIC.play();
function onPause() {
my_MUSIC.pause();
}
document.addEventListener("pause", onPause, false);
function onResume() {
my_MUSIC.play();
}
document.addEventListener("resume", onResume, false);
}