diff options
| author | David Skoland <davidskoland@gmail.com> | 2026-02-07 13:10:27 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2026-02-07 13:10:27 +0100 |
| commit | 0c76b200cc68c59772df930acd34a58bd6272c7f (patch) | |
| tree | 173b1362585945d734f87c9808c618ec55a3d553 /webAO/viewport/utils | |
| parent | 4ab187b991ec40993c4b030e1612d9bb41f18924 (diff) | |
Catch rejected play() promises from browser autoplay policy
Browsers reject .play() with a DOMException when the user hasn't
interacted with the document yet. Add .catch(() => {}) to all 9
play() call sites to suppress the uncaught promise rejection.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'webAO/viewport/utils')
| -rw-r--r-- | webAO/viewport/utils/handleICSpeaking.ts | 2 | ||||
| -rw-r--r-- | webAO/viewport/utils/initTestimonyUpdater.ts | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/webAO/viewport/utils/handleICSpeaking.ts b/webAO/viewport/utils/handleICSpeaking.ts index 6cf665c..ec791c5 100644 --- a/webAO/viewport/utils/handleICSpeaking.ts +++ b/webAO/viewport/utils/handleICSpeaking.ts @@ -169,7 +169,7 @@ export const handle_ic_speaking = async (playerChatMsg: ChatMsg) => { )}/${shout}.opus`; const exists = await fileExists(perCharPath); client.viewport.shoutaudio.src = exists ? perCharPath : client.resources[shout].sfx; - client.viewport.shoutaudio.play(); + client.viewport.shoutaudio.play().catch(() => {}); client.viewport.setShoutTimer(client.resources[shout].duration); } else { client.viewport.setShoutTimer(0); diff --git a/webAO/viewport/utils/initTestimonyUpdater.ts b/webAO/viewport/utils/initTestimonyUpdater.ts index c1e4d93..a545c97 100644 --- a/webAO/viewport/utils/initTestimonyUpdater.ts +++ b/webAO/viewport/utils/initTestimonyUpdater.ts @@ -18,7 +18,7 @@ export const initTestimonyUpdater = () => { } client.viewport.testimonyAudio.src = client.resources[testimony].sfx; - client.viewport.testimonyAudio.play(); + client.viewport.testimonyAudio.play().catch(() => {}); const testimonyOverlay = <HTMLImageElement>( document.getElementById("client_testimony") |
