Patrick_NoD Posted July 5, 2015 Share Posted July 5, 2015 I'm using Construct 2 and having a problem with the background music still playing when the browser is minimized. This is happening on iOS Chrome and the Android stock browser. Weird thing is in iOS Chrome it stops the music if you go to a new tab but not if the browser is minimized. The music stops playing fine in iOS Safari & Android Chrome when new tabs are opened or you minimize the browser. I've tried using the C2 events like Browser > On suspended > Stop All & Stop by nameBrowser > Page is not visible > Stop All & Stop by name which don't work. I checked the JS and have function onVisibilityChanged() {if (document.hidden || document.mozHidden || document.webkitHidden || document.msHidden)cr_setSuspended(true);elsecr_setSuspended(false);}; document.addEventListener("visibilitychange", onVisibilityChanged, false);document.addEventListener("mozvisibilitychange", onVisibilityChanged, false);document.addEventListener("webkitvisibilitychange", onVisibilityChanged, false);document.addEventListener("msvisibilitychange", onVisibilityChanged, false); I don't know if this is browser problem, because sound stops fine on Safari and Android Chrome, just not in iOS Chrome and Android stock browser, or if it's something with my engine. Any help would be appreciated, thanks. Quote Link to comment Share on other sites More sharing options...
gregmax17 Posted July 6, 2015 Share Posted July 6, 2015 Try this:window.addEventListener("focus", onWindowFocus, false);window.addEventListener("blur", onWindowBlur, false); Quote Link to comment Share on other sites More sharing options...
Patrick_NoD Posted July 6, 2015 Author Share Posted July 6, 2015 I tested some Phaser, Construct 2 and Gamemaker HTML5 games out, and it seems to be a problem with the browsers.In games from any engine, the audio does not pause on Android 5.0 stock browser and Chrome for iOS when the browser loses focus and is put into the background, Safari, Chrome for Android and every other browser I tried does. 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.