diff --git a/src/renderer/store/player.store.ts b/src/renderer/store/player.store.ts index e2d5d31d1..bf5c68bfc 100644 --- a/src/renderer/store/player.store.ts +++ b/src/renderer/store/player.store.ts @@ -2234,9 +2234,26 @@ export const usePlayerData = (): PlayerData => { } const currentSong = queue.items[queueIndex]; - const previousSong = queueIndex > 0 ? queue.items[queueIndex - 1] : undefined; const repeat = state.player.repeat; + // For previousSong calculation, we need to consider the shuffled order (only if not in priority mode) + let previousSong: QueueSong | undefined; + if (isShuffleEnabled(state)) { + // Calculate previous in shuffled order + const previousShuffledIndex = index - 1; + if (previousShuffledIndex >= 0) { + const previousQueueIndex = state.queue.shuffled[previousShuffledIndex]; + previousSong = queue.items[previousQueueIndex]; + } else if (repeat === PlayerRepeat.ALL) { + // Wrap to last in shuffled order + const lastShuffledIndex = state.queue.shuffled.length - 1; + const lastQueueIndex = state.queue.shuffled[lastShuffledIndex]; + previousSong = queue.items[lastQueueIndex]; + } + } else { + previousSong = queueIndex > 0 ? queue.items[queueIndex - 1] : undefined; + } + // For nextSong calculation, we need to consider the shuffled order (only if not in priority mode) let nextSong: QueueSong | undefined; if (isShuffleEnabled(state)) {