Skip to content

Commit

Permalink
fix sound turning on/off randomly on first user click due to toggleVo…
Browse files Browse the repository at this point in the history
…lume call
  • Loading branch information
orsi committed Jun 21, 2020
1 parent 2a7f844 commit e260dcf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions script/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e260dcf

Please sign in to comment.