diff --git a/src/lib/components/GlobalPlayer.svelte b/src/lib/components/GlobalPlayer.svelte index 1293062..f7be467 100644 --- a/src/lib/components/GlobalPlayer.svelte +++ b/src/lib/components/GlobalPlayer.svelte @@ -660,9 +660,16 @@ aria-label={isPlaying ? "Pause" : "Play"} title={isPlaying ? "Pause" : "Play"} onclick={() => { - if (!audioEl) return; - if (audioEl.paused) void audioEl.play(); - else audioEl.pause(); + if (!audioEl || !snap.currentTrack) return; + + // If src is not set, it's an initial play action. + // Delegate to syncAndAutoplay to ensure src is set and loaded. + if (!audioEl.src) { + void syncAndAutoplay(); + } else { + if (audioEl.paused) void audioEl.play(); + else audioEl.pause(); + } }} disabled={!snap.currentTrack} > @@ -981,9 +988,16 @@ aria-label={isPlaying ? "Pause" : "Play"} title={isPlaying ? "Pause" : "Play"} onclick={() => { - if (!audioEl) return; - if (audioEl.paused) void audioEl.play(); - else audioEl.pause(); + if (!audioEl || !snap.currentTrack) return; + + // If src is not set, it's an initial play action. + // Delegate to syncAndAutoplay to ensure src is set and loaded. + if (!audioEl.src) { + void syncAndAutoplay(); + } else { + if (audioEl.paused) void audioEl.play(); + else audioEl.pause(); + } }} disabled={!snap.currentTrack} >