diff --git a/lodeRunner.def.js b/lodeRunner.def.js index 843961a..8508ae8 100644 --- a/lodeRunner.def.js +++ b/lodeRunner.def.js @@ -1,4 +1,4 @@ -var VERSION = "2.21d"; +var VERSION = "2.21g"; var AI_VERSION = 4; var NO_OF_TILES_X = 28, diff --git a/lodeRunner.main.js b/lodeRunner.main.js index d7371cb..24906ae 100644 --- a/lodeRunner.main.js +++ b/lodeRunner.main.js @@ -204,6 +204,8 @@ function stopDemoAndPlay() soundStop(soundFall); stopAllSpriteObj(); + resumeAudioContext(); //05/15/2018, chrome 66 default mute autoplay, need resume it + if(playMode == PLAY_DEMO || playMode == PLAY_DEMO_ONCE) selectIconObj.disable(1); if(playMode == PLAY_DEMO_ONCE) showStartMsg = 0; ////genUserLevel(MAX_EDIT_LEVEL); //for debug only diff --git a/lodeRunner.misc.js b/lodeRunner.misc.js index 6181168..f86b2da 100644 --- a/lodeRunner.misc.js +++ b/lodeRunner.misc.js @@ -277,3 +277,30 @@ function getDemoData(playData) playerDemoData[wDemoData[i].level-1] = wDemoData[i]; } } + +//=========================================================================== +// Chrome 66 policy changes default mute autoplay, need resume it +// https://developers.google.com/web/updates/2017/09/autoplay-policy-changes +// +// Reference: https://github.com/CreateJS/SoundJS/issues/297 +//=========================================================================== +function resumeAudioContext() +{ + // handler for fixing suspended audio context in Chrome + //------------------------------------------------------------------ + // Error Msgs: + // "The AudioContext was not allowed to start. + // It must be resume (or created) after a user gesture on the page. + // https://goo.gl/7K7WLu" + //------------------------------------------------------------------ + try { + if (createjs.WebAudioPlugin.context.state === "suspended") { + createjs.WebAudioPlugin.context.resume(); + console.log("Resume Web Audio context..."); + } + } catch (e) { + // SoundJS context or web audio plugin may not exist + console.error("There was an error while trying to resume the SoundJS Web Audio context..."); + console.error(e); + } +} \ No newline at end of file