fix audio context resuming for browsers with no autoplay policy

This commit is contained in:
jorsi
2020-06-08 22:56:05 -04:00
parent dafc86325d
commit f6b7a35a32
2 changed files with 20 additions and 24 deletions
+11 -5
View File
@@ -220,6 +220,7 @@
Events.init();
Room.init();
if(typeof $SM.get('stores.wood') != 'undefined') {
Outside.init();
}
@@ -230,10 +231,6 @@
Ship.init();
}
if(!$SM.get('config.soundOn')){
Engine.toggleVolume();
}
if($SM.get('config.lightsOff', true)){
Engine.turnLightsOff();
}
@@ -242,11 +239,20 @@
Engine.triggerHyperMode();
}
if(!AudioEngine.isAudioContextRunning()){
Engine.toggleVolume();
document.addEventListener('click', Engine.resumeAudioContext);
}
Engine.saveLanguage();
Engine.travelTo(Room);
},
resumeAudioContext: function () {
AudioEngine.tryResumingAudioContext();
Engine.toggleVolume();
document.removeEventListener('click', Engine.resumeAudioContext);
},
browserValid: function() {
return ( location.search.indexOf( 'ignorebrowser=true' ) >= 0 || ( typeof Storage != 'undefined' && !oldIE ) );
},