Android : Cordova: Pause event not firing

on Saturday, September 13, 2014


For some reason the pause event is not firing when it should.


If I press the home button on my phone, this is where the pause event should be fired, which should pause the music. But instead it keeps on playing it.


But when I open my app again it is suddenly paused and then resumed. So it fires both events when I return to the app.


Why is onPause not firing when I leave the app?


I have the following code:



function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
document.addEventListener("resume", onResume, false);
document.addEventListener("pause", onPause, false);
}

function onPause() {
PauseMusic();
alert('paused');
}

function onResume() {
ResumeMusic();
alert('resumed');
}

0 comments:

Post a Comment