fixed repeatOne/ same track twice in a row issues
This commit is contained in:
+19
-1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user