fix queue end handling to prevent repeat

This commit is contained in:
jeffvli
2026-05-28 02:06:07 -07:00
parent 8acd585630
commit 9d53c53c54
2 changed files with 22 additions and 5 deletions
+6 -4
View File
@@ -223,7 +223,7 @@ function calculateNextIndex(
} else {
// Repeat none: move to next track, or pause if at the end
if (isLastTrack) {
return { nextIndex: 0, shouldPause: true };
return { nextIndex: currentIndex, shouldPause: true };
} else {
return { nextIndex: currentIndex + 1, shouldPause: false };
}
@@ -939,10 +939,12 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
const pauseOnNext = player.pauseOnNextSongEnd;
const newStatus =
shouldPause || pauseOnNext ? PlayerStatus.PAUSED : PlayerStatus.PLAYING;
const shouldKeepCurrentPlayer = newStatus === PlayerStatus.PAUSED;
const shouldSwapPlayer = !isRepeatOneSameTrack && !shouldKeepCurrentPlayer;
set((state) => {
state.player.index = nextPlaybackIndex;
state.player.playerNum = newPlayerNum;
state.player.playerNum = shouldSwapPlayer ? newPlayerNum : player.playerNum;
setTimestampStore(0);
state.player.status = newStatus;
@@ -999,7 +1001,7 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
}
const { player1, player2 } = getDualPlayerSongs(
newPlayerNum,
shouldSwapPlayer ? newPlayerNum : player.playerNum,
currentSong,
nextSong,
repeat,
@@ -1009,7 +1011,7 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
currentSong,
index: currentQueueIndex,
nextSong,
num: newPlayerNum,
num: shouldSwapPlayer ? newPlayerNum : player.playerNum,
player1,
player2,
previousSong,