diff options
| -rw-r--r-- | webAO/client.html | 2 | ||||
| -rw-r--r-- | webAO/client.js | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/webAO/client.html b/webAO/client.html index 99a5910..b5392ee 100644 --- a/webAO/client.html +++ b/webAO/client.html @@ -371,7 +371,7 @@ <audio id="client_sfxaudio" onvolumechange="changeSFXVolume()" controls></audio> <p>Shouts</p> - <audio id="client_shoutaudio" onvolumechange="changeShoutVolume()" controls></audio> + <audio id="client_shoutaudio" onvolumechange="changeShoutVolume()" onerror="shoutMissing(this)" controls></audio> <p>Testimony/Guilty</p> <audio id="client_testimonyaudio" onvolumechange="changeTestimonyVolume()" controls></audio> diff --git a/webAO/client.js b/webAO/client.js index a44f9d5..4a9e934 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1916,19 +1916,7 @@ async changeBackground(position) { shoutSprite.style.opacity = 1; - let shoutUrl; - - try { - const { url: soundUrl } = await this.oneSuccess([ - this.rejectOnError(fetch(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`)), - this.rejectOnError(fetch(`${AO_HOST}misc/default/objection.wav`)) - ]); - shoutUrl = soundUrl; - } catch (error) { - shoutUrl = AO_HOST + `${AO_HOST}misc/default/objection.wav`; - } - - this.shoutaudio.src = shoutUrl; + this.shoutaudio.src = `${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`; this.shoutaudio.play(); this.shoutTimer = client.resources[shout]["duration"]; } else { @@ -2439,6 +2427,15 @@ export function changeShoutVolume() { window.changeShoutVolume = changeShoutVolume; /** + * Triggered when the shout could not be found + */ +export function shoutMissing(self) { + self.src = AO_HOST + `${AO_HOST}misc/default/objection.opus`; + self.play(); +} +window.shoutMissing = shoutMissing; + +/** * Triggered by the testimony volume slider. */ export function changeTestimonyVolume() { |
