diff options
| author | stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> | 2020-11-09 20:42:53 +0100 |
|---|---|---|
| committer | stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> | 2020-11-09 20:42:53 +0100 |
| commit | 4c91874c653536a357f0f737190e1ea617df36f5 (patch) | |
| tree | b238853acdeb52b07aa35947c82775cb2c710000 /webAO | |
| parent | c26cd57c3f05ffe6db08d2ef8aaaf9a73ca5f74b (diff) | |
greatly simplify missing shout logic
Diffstat (limited to 'webAO')
| -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() { |
