Disable audio until bugs and hosting can be worked out

This commit is contained in:
Michael Townsend
2020-10-05 12:23:08 -04:00
parent a601473645
commit 9e19425a9e
2 changed files with 36 additions and 20 deletions
+22
View File
@@ -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);
@@ -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);