AB95 Posted February 3, 2017 Share Posted February 3, 2017 Hi everyone, i was trying to pause a scene when the browser window is not active(eg. user switches tab, ctrl/cmd+tab, another window is currently focus,etc). To pause the scene, i need the background music and all animations to be paused, below playground example shows my approach: http://babylonjs-playground.com/#1MZCTQ I got two results: 1. when I click on another window(for example a notepad) that overlapped the browser, the notepad is now focus and the browser is blur, hence both sound and animation are paused, this is expected; 2. when I ctrl/cmd+tab or manually click on another tab to switch tab, only sound is paused but the animation continues playing. looks like $(window).blur(function() {...}); is triggered, but only bgm.pause() work, anim.pause() doesn't work. $(window).focus(function() { anim.restart(); bgm.play(); }); $(window).blur(function() { anim.pause(); bgm.pause(); }); any help will be appreciated, thank you! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 3, 2017 Share Posted February 3, 2017 Hello! this is because the tab is completely stopped by the browser when you switch to another tab and thus, babylon.js has no time to run the required code. Here is a fix for you:http://babylonjs-playground.com/#1MZCTQ#1 AB95 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted February 3, 2017 Share Posted February 3, 2017 Post deleted answer not correct Quote Link to comment Share on other sites More sharing options...
AB95 Posted February 5, 2017 Author Share Posted February 5, 2017 @Deltakosh thank you for the solution! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.