Jump to content

Pausing sound when you click off the browser


Gameventions
 Share

Recommended Posts

So I have some cut scenes in my game that have simple audio and events tied to the timer to display animations on the screen.  The problem is when i click off the browser,  the animation time stops,  but the sound loop while it stops 'playing' keeps progressing.  

 

So basically start cut scene timers in sinc.  At 5 seconds i click onto another window.  wait 5 seconds and click back on the game,  sound will be at 10 seconds, but the animation at 5.  Anyway to make sure these sync up whether people click off the window or not?

Link to comment
Share on other sites

  • 4 weeks later...

You can check for the onBlur and onFocus Event and pause/unpause the current running sounds.

		create: function(){		this.game.onBlur.add(this.onInactive, this);		this.game.onBlur.add(this.onResume, this);	},	onInactive: function(){					console.log('now is inactive');		// now pause all the running sound		this.game.sound.pauseAll();	},	onResume: function(){					console.log('now resume');		// now resume all the running sound		this.game.sound.resumeAll();	},

I did not try it. I was just looking things up in the docs. But the principle should work..

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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