Skip to content

Commit

Permalink
ui/player/queue: Ensure first media item is not reloaded on playlist …
Browse files Browse the repository at this point in the history
…repeat
  • Loading branch information
darkhz committed Jan 31, 2024
1 parent 30f9585 commit e556d34
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ui/player/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ func (q *Queue) AutoPlay(force bool) {

case mp.RepeatModePlaylist:
if !q.shuffle.Load() && q.Position() == q.Count()-1 {
q.SwitchToPosition(0)
q.SwitchToPosition(0, struct{}{})
q.MarkPlayingEntry(EntryPlaying)
return
}
}
Expand Down Expand Up @@ -360,14 +361,16 @@ func (q *Queue) SetPosition(position int) {
}

// SwitchToPosition switches to the specified position within the queue.
func (q *Queue) SwitchToPosition(position int) {
func (q *Queue) SwitchToPosition(position int, autoplay ...struct{}) {
q.storeMutex.Lock()
defer q.storeMutex.Unlock()

data, ok := q.GetEntryPointer(position)
if !ok {
return
}

skipPlaying := autoplay != nil && position == 0 && data == q.current
if q.current != nil {
q.current.Playing = false
}
Expand All @@ -377,6 +380,10 @@ func (q *Queue) SwitchToPosition(position int) {

q.current = data

if skipPlaying {
return
}

q.SetPosition(position)
q.Play()
}
Expand Down

0 comments on commit e556d34

Please sign in to comment.