fix web player resuming on queue modification (#2250)

- During queue edits, stream URL reloads briefly reported a bogus duration (~0.07s). The gapless handler treated that as near end-of-track and called .play() while the player was still paused
This commit is contained in:
jeffvli
2026-07-21 00:29:20 -07:00
parent d991d4e1b8
commit 390b231e06
2 changed files with 39 additions and 2 deletions
@@ -136,6 +136,10 @@ export function WebPlayer() {
return;
}
if (usePlayerStoreBase.getState().player.status !== PlayerStatus.PLAYING) {
return;
}
switch (transitionType) {
case PlayerStyle.CROSSFADE:
crossfadeHandler({
@@ -195,6 +199,10 @@ export function WebPlayer() {
return;
}
if (usePlayerStoreBase.getState().player.status !== PlayerStatus.PLAYING) {
return;
}
switch (transitionType) {
case PlayerStyle.CROSSFADE:
crossfadeHandler({
@@ -286,6 +294,11 @@ export function WebPlayer() {
onCurrentSongChange: () => {
setIsTransitioning(false);
},
onPlayerQueueChange: () => {
if (usePlayerStoreBase.getState().player.status !== PlayerStatus.PLAYING) {
setIsTransitioning(false);
}
},
onPlayerSeekToTimestamp: (properties) => {
setIsTransitioning(false);
@@ -607,6 +620,13 @@ function crossfadeHandler(args: {
} = args;
const player = `player${playerNum}`;
if (usePlayerStoreBase.getState().player.status !== PlayerStatus.PLAYING) {
if (isTransitioning) {
setIsTransitioning(false);
}
return;
}
// If there is no next song to transition to, ensure we don't enter or stay in a transition
if (!hasNextSong) {
currentPlayer.setVolume(volume);
@@ -714,10 +734,25 @@ function gaplessHandler(args: {
setIsTransitioning,
} = args;
if (usePlayerStoreBase.getState().player.status !== PlayerStatus.PLAYING) {
if (isTransitioning) {
setIsTransitioning(false);
}
return null;
}
if (!hasNextSong) {
return null;
}
// Ignore invalid durations (e.g. during URL load or empty source placeholder)
if (!Number.isFinite(duration) || duration < 2) {
if (isTransitioning) {
setIsTransitioning(false);
}
return null;
}
if (!isTransitioning) {
if (currentTime > duration - 2) {
return setIsTransitioning(true);