fixed initial track playback

This commit is contained in:
2026-02-06 06:50:44 -08:00
parent 3401967d7c
commit 5a920de85d

View File

@@ -660,9 +660,16 @@
aria-label={isPlaying ? "Pause" : "Play"} aria-label={isPlaying ? "Pause" : "Play"}
title={isPlaying ? "Pause" : "Play"} title={isPlaying ? "Pause" : "Play"}
onclick={() => { onclick={() => {
if (!audioEl) return; if (!audioEl || !snap.currentTrack) return;
if (audioEl.paused) void audioEl.play();
else audioEl.pause(); // 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} disabled={!snap.currentTrack}
> >
@@ -981,9 +988,16 @@
aria-label={isPlaying ? "Pause" : "Play"} aria-label={isPlaying ? "Pause" : "Play"}
title={isPlaying ? "Pause" : "Play"} title={isPlaying ? "Pause" : "Play"}
onclick={() => { onclick={() => {
if (!audioEl) return; if (!audioEl || !snap.currentTrack) return;
if (audioEl.paused) void audioEl.play();
else audioEl.pause(); // 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} disabled={!snap.currentTrack}
> >