fixed initial track playback
This commit is contained in:
@@ -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}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user