Skip to content

Commit

Permalink
fix: playlist backward loop
Browse files Browse the repository at this point in the history
  • Loading branch information
darekaze committed Jul 26, 2022
1 parent 71189c2 commit b1f7710
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/player/store/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export const usePlayerState = defineStore('player', () => {
const skipTrack = (forward = true) => {
if (playlist.currentPlaylist?.length <= 1) return

playlist.index =
playlist.index < 0
? playlist.currentPlaylist.length - 1
: (playlist.index + (forward ? 1 : -1)) % playlist.currentPlaylist.length
if (!forward && playlist.index <= 0) {
playlist.index = playlist.currentPlaylist.length - 1
} else {
playlist.index = (playlist.index + (forward ? 1 : -1)) % playlist.currentPlaylist.length
}

startAudio()
}
Expand Down

1 comment on commit b1f7710

@vercel
Copy link

@vercel vercel bot commented on b1f7710 Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

campion – ./

campion.vercel.app
campion-darekaze.vercel.app
campion-git-main-darekaze.vercel.app

Please sign in to comment.