Jump to content

Music not stopping when browser minimized?


 Share

Recommended Posts

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 name

Browser > 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);
else
cr_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.
Link to comment
Share on other sites

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.

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...