Jump to content

how to stop music when leave the application on phone ?


espace
 Share

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;
};

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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