aduros / flambe

Rapidly cook up games for HTML5, Flash, Android, and iOS.
https://github.com/aduros/flambe/wiki
MIT License
745 stars 118 forks source link

[request] Toggle Mute on Window Blur/Focus #336

Open BBaysinger opened 9 years ago

BBaysinger commented 9 years ago

Should be a way to pause/un-pause playbacks when browser window focus changes. Currently only does so when minimized or switched to a background tab. Seems like this would require a new property on System that would emit the state change in window focus.

markknol commented 9 years ago

There is System.hidden https://aduros.com/flambe/api/flambe/System.html#hidden

I think such feature would work inconsistent for each platform; in flash you lose focus when clicking outside flash, in html on the window focus. If the game isn't fullscreen that will be noticeable.

You can always listen to such features yourself.

#if js
Browser.window.addEventListener("focus", onWindowFocus, false);
Browser.window.addEventListener("blur", onWindowBlur, false);
#end
BBaysinger commented 9 years ago

System.hidden does not dispatch on window focus changes, only when minimized or switched to background tab. I believe we could make the behaviors consistent between HTML and Flash, maybe by using ExternalInterface to detect focus and blur in JS.

This was a request from our client, and it's come up several times now. I may have time to crack into it after this project, but just want to see if anyone has any thoughts on it.