fix sound turning on/off randomly on first user click due to toggleVolume call

This commit is contained in:
jorsi
2020-06-21 14:05:19 -04:00
parent 2a7f8441dd
commit e260dcfff3
+9 -3
View File
@@ -240,17 +240,23 @@
}
if(!AudioEngine.isAudioContextRunning()){
Engine.toggleVolume();
document.addEventListener('click', Engine.resumeAudioContext);
}
Engine.saveLanguage();
Engine.travelTo(Room);
},
resumeAudioContext: function () {
AudioEngine.tryResumingAudioContext();
Engine.toggleVolume();
// turn on music!
if (AudioEngine._audioContext.state !== 'suspended') {
$('.volume').text(_('sound off.'));
$SM.set('config.soundOn', true);
AudioEngine.setMasterVolume(1.0);
}
document.removeEventListener('click', Engine.resumeAudioContext);
},
browserValid: function() {