fixed incorrect isPlaying state when shuffled

This commit is contained in:
austinried 2021-08-11 13:39:58 +09:00
parent ea45678733
commit 9fda955df6

View File

@ -246,11 +246,16 @@ export const useSetQueue = () => {
export const useIsPlaying = () => {
const queueContextId = useStore(selectTrackPlayer.queueContextId)
const currentTrackIdx = useStore(selectTrackPlayer.currentTrackIdx)
const shuffleOrder = useStore(selectTrackPlayer.shuffleOrder)
return (contextId: string | undefined, track: number) => {
if (contextId === undefined) {
return track === currentTrackIdx
}
if (shuffleOrder) {
const shuffledTrack = shuffleOrder.findIndex(i => i === track)
track = shuffledTrack !== undefined ? shuffledTrack : -1
}
return contextId === queueContextId && track === currentTrackIdx
}
}