fix(web): trigger audio.play() during 'loading' state, not only 'playing'
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user