fixed repeatOne/ same track twice in a row issues

This commit is contained in:
2026-02-16 02:45:51 -05:00
parent 95e1b32e86
commit 419fec1672
4 changed files with 33 additions and 6 deletions
+19 -1
View File
@@ -653,7 +653,8 @@ func (q *Queue) RemoveTrack(position int) {
q.emitQueueChanged()
}
// Next advances to the next track.
// Next advances to the next track. In RepeatOne mode, the current
// track is replayed instead of advancing.
func (q *Queue) Next() {
q.mu.Lock()
defer q.mu.Unlock()
@@ -662,6 +663,14 @@ func (q *Queue) Next() {
return
}
// Repeat One: replay the current track.
if q.repeatMode == RepeatOne {
q.playCurrentTrack()
q.emitQueueChanged()
return
}
nextIdx := q.nextIndex()
if nextIdx == -1 {
q.onQueueExhausted()
@@ -675,6 +684,7 @@ func (q *Queue) Next() {
}
// Previous goes to the previous track (or restarts current if >3s in).
// In RepeatOne mode, the current track is replayed instead of navigating.
func (q *Queue) Previous() {
q.mu.Lock()
defer q.mu.Unlock()
@@ -683,6 +693,14 @@ func (q *Queue) Previous() {
return
}
// Repeat One: replay the current track.
if q.repeatMode == RepeatOne {
q.playCurrentTrack()
q.emitQueueChanged()
return
}
// If more than 3 seconds into the track, restart it.
if q.player != nil {
posSecs, err := q.player.CurrentPositionSeconds()