Skip to content

Commit

Permalink
fix: useIsPlaying hook does not cover 'none' state (#2125)
Browse files Browse the repository at this point in the history
In case if there is only one track in queue, after removing the track
the hook is still returing playing as true. There is no condition
which is checking 'none' state.
  • Loading branch information
sergeiten authored Sep 14, 2023
1 parent 7eea8a2 commit 1a6bc5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hooks/useIsPlaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ function determineIsPlaying(playWhenReady?: boolean, state?: State) {
const isLoading = state === State.Loading || state === State.Buffering;
const isErrored = state === State.Error;
const isEnded = state === State.Ended;
const isNone = state === State.None;

return {
playing: playWhenReady && !(isErrored || isEnded),
playing: playWhenReady && !(isErrored || isEnded || isNone),
bufferingDuringPlay: playWhenReady && isLoading,
};
}
Expand Down

0 comments on commit 1a6bc5b

Please sign in to comment.