Stefano

Members
  • Content Count

    1
  • Joined

  • Last visited

About Stefano

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, I am new in this forum and I hope to find an answer for my problem. I have developed a game that will runs in a webview under Android, but when the music is playing and we press 'lock button' phone, the screen is black but the music runs again. I have added all check to know if the HTML lost focus, but nothing works... Do you have some idea? Thanks!!! 😅 This is the coded added for check when the HTML lost focus (works fine in browser but under webview no :( ) <script type="text/javascript"> // Howler.mobileAutoEnable = true; controls.mute = function () { if (typeof Howler !== 'undefined' && typeof Howler.mute === 'function') { Howler.mute(true); return 'controls: done'; } return 'controls: failed'; }; controls.unmute = function () { if (typeof Howler !== 'undefined' && typeof Howler.mute === 'function') { Howler.mute(false); return 'controls: done'; } return 'controls: failed'; }; //---------------------------------------------------------------------------------------------------- // Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; } else if (typeof document.webkitHidden !== "undefined") {. hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; } function handleVisibilityChange() { if (document[hidden]) { controls.mute(); } else { controls.unmute(); } } // Warn if the browser doesn't support addEventListener or the Page Visibility API if (typeof document.addEventListener === "undefined" || hidden === undefined) { console.log("VisibilityChange requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API."); } else { // Handle page visibility change document.addEventListener(visibilityChange, handleVisibilityChange, false); } //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- window.onfocus = function () { if(typeof controls !== 'undefined' && controls != null) if(controls.unmute != null) controls.unmute(); } window.onblur = function () { if(typeof controls !== 'undefined' && controls != null) if(controls.unmute != null) controls.mute(); } //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- // Handle page visibility change events function handleVisibilityChange() { if (document.visibilityState == "hidden") { controls.mute(); } else { controls.unmute(); } } document.addEventListener('visibilitychange', handleVisibilityChange, false); //---------------------------------------------------------------------------------------------------- </script>