From 4264ecf538d7f56986979b306a90021f0efa5436 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 24 Apr 2026 22:12:34 -0400 Subject: [PATCH] fix(web): trigger audio.play() during 'loading' state, not only 'playing' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The layout's play-intent effect gated audioEl.play() on player.isPlaying (state === 'playing'), but the state progression is loading → DOM play() → 'playing' event → state='playing'. Without calling play() during loading, the DOM never starts, the event never fires, and state is pinned to loading forever. Call play() for the intent-to-play union (loading + playing), matching the store's design. --- web/src/routes/+layout.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index d1e22e3d..50784575 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -53,7 +53,10 @@ $effect(() => { if (!audioEl) return; - if (player.isPlaying) { + // "Intent to play" = loading or playing. During 'loading' the DOM hasn't + // emitted 'playing' yet, but we still need to call play() to get there. + const intent = player.state === 'playing' || player.state === 'loading'; + if (intent) { audioEl.play().catch(() => { /* interrupted / blocked — store gets the event */ }); } else { audioEl.pause();