mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-19 18:04:22 +02:00
Web player fixes
This commit is contained in:
@@ -78,13 +78,13 @@ export const AudioPlayer = forwardRef(
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === PlayerStatus.PLAYING) {
|
if (status === PlayerStatus.PLAYING) {
|
||||||
if (currentPlayer === 1) {
|
if (currentPlayer === 1) {
|
||||||
player1Ref.current.getInternalPlayer().play();
|
player1Ref.current?.getInternalPlayer()?.play();
|
||||||
} else {
|
} else {
|
||||||
player2Ref.current.getInternalPlayer().play();
|
player2Ref.current?.getInternalPlayer()?.play();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player1Ref.current.getInternalPlayer().pause();
|
player1Ref.current?.getInternalPlayer()?.pause();
|
||||||
player2Ref.current.getInternalPlayer().pause();
|
player2Ref.current?.getInternalPlayer()?.pause();
|
||||||
}
|
}
|
||||||
}, [currentPlayer, status]);
|
}, [currentPlayer, status]);
|
||||||
|
|
||||||
|
|||||||
@@ -113,24 +113,12 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
|||||||
}, [repeat, setRepeat]);
|
}, [repeat, setRepeat]);
|
||||||
|
|
||||||
const checkIsLastTrack = useCallback(() => {
|
const checkIsLastTrack = useCallback(() => {
|
||||||
const currentIndex =
|
return usePlayerStore.getState().checkIsLastTrack();
|
||||||
shuffle === PlayerShuffle.NONE
|
}, []);
|
||||||
? usePlayerStore.getState().current.index
|
|
||||||
: usePlayerStore.getState().current.shuffledIndex;
|
|
||||||
|
|
||||||
const queueLength = queue.length;
|
|
||||||
|
|
||||||
return currentIndex >= queueLength - 1;
|
|
||||||
}, [queue.length, shuffle]);
|
|
||||||
|
|
||||||
const checkIsFirstTrack = useCallback(() => {
|
const checkIsFirstTrack = useCallback(() => {
|
||||||
const currentIndex =
|
return usePlayerStore.getState().checkIsFirstTrack();
|
||||||
shuffle === PlayerShuffle.NONE
|
}, []);
|
||||||
? usePlayerStore.getState().current.index
|
|
||||||
: usePlayerStore.getState().current.shuffledIndex;
|
|
||||||
|
|
||||||
return currentIndex === 0;
|
|
||||||
}, [shuffle]);
|
|
||||||
|
|
||||||
const handleAutoNext = useCallback(() => {
|
const handleAutoNext = useCallback(() => {
|
||||||
const isLastTrack = checkIsLastTrack();
|
const isLastTrack = checkIsLastTrack();
|
||||||
@@ -162,6 +150,7 @@ export const useCenterControls = (args: { playersRef: any }) => {
|
|||||||
web: () => {
|
web: () => {
|
||||||
if (isLastTrack) {
|
if (isLastTrack) {
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
|
pause();
|
||||||
} else {
|
} else {
|
||||||
autoNext();
|
autoNext();
|
||||||
resetPlayers();
|
resetPlayers();
|
||||||
|
|||||||
Reference in New Issue
Block a user