diff options
Diffstat (limited to 'webAO/client.js')
| -rw-r--r-- | webAO/client.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/webAO/client.js b/webAO/client.js index 9b17528..01413a8 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -758,7 +758,7 @@ class Client extends EventEmitter { const showname = args[3] || ""; const looping = Boolean(args[4]); const channel = Number(args[5]) || 0; - const fading = Number(args[6]) || 0; // unused in web + // const fading = Number(args[6]) || 0; // unused in web const music = viewport.music[channel]; let musicname; @@ -1648,6 +1648,7 @@ class Viewport { new Audio(AO_HOST + "sounds/general/sfx-blipmale.opus"), new Audio(AO_HOST + "sounds/general/sfx-blipmale.opus")); this.blipChannels.forEach(channel => channel.volume = 0.5); + this.blipChannels.forEach(channel => channel.onerror = opusCheck(channel)); this.currentBlipChannel = 0; this.sfxaudio = document.getElementById("client_sfxaudio"); @@ -1666,6 +1667,7 @@ class Viewport { new Audio(`${AO_HOST}sounds/music/trial (aa).opus`), new Audio(`${AO_HOST}sounds/music/trial (aa).opus`)); this.music.forEach(channel => channel.volume = 0.5); + this.music.forEach(channel => channel.onerror = opusCheck(channel)); this.updater = null; this.testimonyUpdater = null; @@ -2692,6 +2694,23 @@ export function imgError(image) { window.imgError = imgError; /** + * Triggered when there was an error loading a sound + * @param {HTMLImageElement} image the element containing the missing sound + */ + export function opusCheck(channel) { + console.info(channel) + console.info("failed to load sound "+channel.src) + let oldsrc = "" + oldsrc = channel.src + if(!oldsrc.endsWith(".opus")) { + newsrc = oldsrc.replace(".mp3",".opus") + newsrc = newsrc.replace(".wav",".opus") + channel.src = newsrc; //unload so the old sprite doesn't persist + } +} +window.opusCheck = opusCheck; + +/** * Make a GET request for a specific URI. * @param {string} url the URI to be requested * @returns response data |
