espace

how to stop music when leave the application on phone ?

Recommended Posts

hi,

I have this piece of code to play my ambiance music. these function is on the top of my state to be accessible trough all the different states.

Everything works fine expect when i leave the game on my phone. The music is still playing.

What's the syntax for the  event : to say "we leave the game" then stop the music with music_ambiance.pause(); ?

var music_ambiance=new Audio('sounds/music_ambiance/mus.ogg');

music_ambiance.loop=true;
music_ambiance.volume=0.20;

music_ambiance.play();
//for pause 
//music_ambiance.pause();

music_ambiance_mute=function(){
  music_ambiance.volume=0;
};

music_ambiance_activate=function(){
  music_ambiance.volume=0.20;
};

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.