From 0c76b200cc68c59772df930acd34a58bd6272c7f Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 7 Feb 2026 13:10:27 +0100 Subject: 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 --- webAO/viewport/viewport.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webAO/viewport/viewport.ts') diff --git a/webAO/viewport/viewport.ts b/webAO/viewport/viewport.ts index c03d750..a7363a9 100644 --- a/webAO/viewport/viewport.ts +++ b/webAO/viewport/viewport.ts @@ -104,7 +104,7 @@ const viewport = (): Viewport => { sfxAudio.pause(); sfxAudio.loop = looping; sfxAudio.src = sfxname; - sfxAudio.play(); + sfxAudio.play().catch(() => {}); }; /** * Updates the testimony overaly @@ -150,7 +150,7 @@ const viewport = (): Viewport => { const charEmote = chatmsg.sprite.toLowerCase(); if (chatmsg.content.charAt(textnow.length) !== " ") { - blipChannels[currentBlipChannel].play(); + blipChannels[currentBlipChannel].play().catch(() => {}); currentBlipChannel++; currentBlipChannel %= blipChannels.length; } @@ -356,7 +356,7 @@ const viewport = (): Viewport => { eviBox.style.opacity = "1"; testimonyAudio.src = `${AO_HOST}sounds/general/sfx-evidenceshoop.opus`; - testimonyAudio.play(); + testimonyAudio.play().catch(() => {}); if (chatmsg.side === "def") { // Only def show evidence on right -- cgit