Reputation: 2067
I'm using the howerjs audio library for my game that I am creating with Cordova. How can I disable the entire app or pause the audio when the user leaves the app? Right now the music continues to play. Is there a hook?
Upvotes: 0
Views: 216
Reputation: 5115
You could attach a function to the pause event. This method is thrown by Cordova when the application moves to the background.
document.addEventListener("pause", onPause, false);
function onPause() {
// audio.pause();
}
Upvotes: 1