cordova - How can I pause audio when an Android app is suspended - Edge Animate and PhoneGap Build -


i have app built in edge animate , packaged phonegap build.

the app works fine but, when use home or button on android device exit app, audio continues play though app appears suspend , go background. not case ios version.

is there way mute or pause audio on 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 .html , in edgeactions.js no success.

i have tried using;

<preference name="keeprunning" value="false"/> 

in config.xml, still keeps running.

i have run out of ideas , can't find answers on internet.

thanks help

i have working...

function loopmusic(url) { // play audio file @ 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); } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -