mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-10 22:32:17 +02:00
fix queue end handling to prevent repeat
This commit is contained in:
@@ -153,6 +153,7 @@ export function WebPlayer() {
|
||||
gaplessHandler({
|
||||
currentTime: e.playedSeconds,
|
||||
duration: getDuration(playerRef.current.player1().ref),
|
||||
hasNextSong: Boolean(player2),
|
||||
isFlac: false,
|
||||
isTransitioning,
|
||||
nextPlayer: playerRef.current.player2(),
|
||||
@@ -206,6 +207,7 @@ export function WebPlayer() {
|
||||
gaplessHandler({
|
||||
currentTime: e.playedSeconds,
|
||||
duration: getDuration(playerRef.current.player2().ref),
|
||||
hasNextSong: Boolean(player1),
|
||||
isFlac: false,
|
||||
isTransitioning,
|
||||
nextPlayer: playerRef.current.player1(),
|
||||
@@ -680,6 +682,7 @@ function exponentialEaseOut(t: number): number {
|
||||
function gaplessHandler(args: {
|
||||
currentTime: number;
|
||||
duration: number;
|
||||
hasNextSong: boolean;
|
||||
isFlac: boolean;
|
||||
isTransitioning: boolean | string;
|
||||
nextPlayer: {
|
||||
@@ -688,7 +691,19 @@ function gaplessHandler(args: {
|
||||
};
|
||||
setIsTransitioning: Dispatch<boolean | string>;
|
||||
}) {
|
||||
const { currentTime, duration, isFlac, isTransitioning, nextPlayer, setIsTransitioning } = args;
|
||||
const {
|
||||
currentTime,
|
||||
duration,
|
||||
hasNextSong,
|
||||
isFlac,
|
||||
isTransitioning,
|
||||
nextPlayer,
|
||||
setIsTransitioning,
|
||||
} = args;
|
||||
|
||||
if (!hasNextSong) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isTransitioning) {
|
||||
if (currentTime > duration - 2) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user