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/packets/handlers/handleMC.ts | |
| 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/packets/handlers/handleMC.ts')
| -rw-r--r-- | webAO/packets/handlers/handleMC.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/webAO/packets/handlers/handleMC.ts b/webAO/packets/handlers/handleMC.ts index 8a1c0a2..44237ea 100644 --- a/webAO/packets/handlers/handleMC.ts +++ b/webAO/packets/handlers/handleMC.ts @@ -24,7 +24,7 @@ export const handleMC = (args: string[]) => { music.src = `${AO_HOST}sounds/music/${encodeURI(track.toLowerCase())}`; } music.loop = looping; - music.play(); + music.play().catch(() => {}); try { musicname = client.chars[charID].name; |
