Skip to content

Commit

Permalink
Disable audio until bugs and hosting can be worked out
Browse files Browse the repository at this point in the history
  • Loading branch information
Continuities committed Oct 5, 2020
1 parent a601473 commit 9e19425
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
22 changes: 22 additions & 0 deletions script/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ var AudioEngine = {
_currentBackgroundMusic: null,
_currentEventAudio: null,
_currentSoundEffectAudio: null,
_initialized: false,
init: function () {
AudioEngine._initAudioContext();
// start loading music and events early
for (var key in AudioLibrary) {
if (
key.toString().indexOf('MUSIC_') > -1 ||
key.toString().indexOf('EVENT_') > -1) {
AudioEngine.loadAudioFile(AudioLibrary[key]);
}
}
AudioEngine._initialized = true;
},
_initAudioContext: function () {
AudioEngine._audioContext = new (window.AudioContext || window.webkitAudioContext);
Expand Down Expand Up @@ -152,21 +162,33 @@ var AudioEngine = {
}
},
playBackgroundMusic: function (src) {
if (!AudioEngine._initialized) {
return;
}
AudioEngine.loadAudioFile(src)
.then(function (buffer) {
AudioEngine._playBackgroundMusic(buffer);
});
},
playEventMusic: function (src) {
if (!AudioEngine._initialized) {
return;
}
AudioEngine.loadAudioFile(src)
.then(function (buffer) {
AudioEngine._playEventMusic(buffer);
});
},
stopEventMusic: function () {
if (!AudioEngine._initialized) {
return;
}
AudioEngine._stopEventMusic();
},
playSound: function (src) {
if (!AudioEngine._initialized) {
return;
}
AudioEngine.loadAudioFile(src)
.then(function (buffer) {
AudioEngine._playSound(buffer);
Expand Down
34 changes: 14 additions & 20 deletions script/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@
Engine.loadGame();
}

// start loading music and events early
for (var key in AudioLibrary) {
if (
key.toString().indexOf('MUSIC_') > -1 ||
key.toString().indexOf('EVENT_') > -1) {
AudioEngine.loadAudioFile(AudioLibrary[key]);
}
}

$('<div>').attr('id', 'locationSlider').appendTo('#main');

var menu = $('<div>')
Expand Down Expand Up @@ -142,11 +133,12 @@
});
}

$('<span>')
.addClass('volume menuBtn')
.text(_('sound on.'))
.click(() => Engine.toggleVolume())
.appendTo(menu);
// Disable this for now
// $('<span>')
// .addClass('volume menuBtn')
// .text(_('sound on.'))
// .click(() => Engine.toggleVolume())
// .appendTo(menu);

$('<span>')
.addClass('appStore menuBtn')
Expand Down Expand Up @@ -215,7 +207,7 @@
$.Dispatch('stateUpdate').subscribe(Engine.handleStateUpdates);

$SM.init();
AudioEngine.init();
// AudioEngine.init(); Disable this for now
Notifications.init();
Events.init();
Room.init();
Expand All @@ -239,15 +231,17 @@
Engine.triggerHyperMode();
}

Engine.toggleVolume(Boolean($SM.get('config.soundOn')));
if(!AudioEngine.isAudioContextRunning()){
document.addEventListener('click', Engine.resumeAudioContext, true);
}
// Disable this for now
// Engine.toggleVolume(Boolean($SM.get('config.soundOn')));
// if(!AudioEngine.isAudioContextRunning()){
// document.addEventListener('click', Engine.resumeAudioContext, true);
// }

Engine.saveLanguage();
Engine.travelTo(Room);

setTimeout(notifyAboutSound, 3000);
// Disable this for now
// setTimeout(notifyAboutSound, 3000);

},
resumeAudioContext: function () {
Expand Down

0 comments on commit 9e19425

Please sign in to comment.