Jump to content

stop music when leave application on phone with the home button?


espace
 Share

Recommended Posts

hi,

the background music of my application is still playing when i leave the application. the back button stop the music  (left button) but not the home button (middle button)

YKCPp.png

here is the code of my background music :

		music=game.add.audio('music');
	        music.volume=0.4
		music.play();

i try different approach but nothing works :

//approach 1
// in index.html
document.addEventListener("pause",onPause,false)
function onPause(){
	music.pause();

};

// => don't works

//approach 2
//in main.js
function update(){
	if(game.stage.disableVisibilityChange){
		music.pause()
	}	
};
// => don't works

 

what must i add to avoid this ? thanks for your assistance.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...