setPlayQueue func

This commit is contained in:
Siiiiinth
2026-02-15 09:28:38 -08:00
committed by Drew Weymouth
parent 83edeafe7c
commit 72f2068dc3
+12 -4
View File
@@ -233,6 +233,14 @@ func (p *playbackEngine) clearPlayQueue() {
p.playQueueShuffle = nil p.playQueueShuffle = nil
} }
func (p *playbackEngine) setPlayQueue(items []mediaprovider.MediaItem) {
if p.shuffle {
p.playQueueShuffle = items
} else {
p.playQueue = items
}
}
func (p *playbackEngine) PlayTrackAt(idx int) error { func (p *playbackEngine) PlayTrackAt(idx int) error {
return p.playTrackAt(idx, 0) return p.playTrackAt(idx, 0)
} }
@@ -414,7 +422,7 @@ func (p *playbackEngine) doLoaditems(items []mediaprovider.MediaItem, insertQueu
if insertQueueMode == InsertNext { if insertQueueMode == InsertNext {
insertIdx = p.nowPlayingIdx + 1 insertIdx = p.nowPlayingIdx + 1
} }
p.playQueue = append(p.playQueue[:insertIdx], append(items, p.playQueue[insertIdx:]...)...) p.setPlayQueue(append(p.playQueue[:insertIdx], append(items, p.playQueue[insertIdx:]...)...))
p.invokeNoArgCallbacks(p.onQueueChange) p.invokeNoArgCallbacks(p.onQueueChange)
return nil return nil
@@ -438,7 +446,7 @@ func (p *playbackEngine) LoadRadioStation(radio *mediaprovider.RadioStation, ins
copy(new, firstHalf) copy(new, firstHalf)
new[len(firstHalf)] = radio new[len(firstHalf)] = radio
copy(new[len(firstHalf)+1:], p.playQueue[insertIdx:]) copy(new[len(firstHalf)+1:], p.playQueue[insertIdx:])
p.playQueue = new p.setPlayQueue(new)
p.invokeNoArgCallbacks(p.onQueueChange) p.invokeNoArgCallbacks(p.onQueueChange)
} }
@@ -494,7 +502,7 @@ func (p *playbackEngine) UpdatePlayQueue(items []mediaprovider.MediaItem) error
} }
} }
p.playQueue = newQueue p.setPlayQueue(newQueue)
if p.nowPlayingIdx >= 0 && newNowPlayingIdx == -1 { if p.nowPlayingIdx >= 0 && newNowPlayingIdx == -1 {
return p.Stop() return p.Stop()
} }
@@ -533,7 +541,7 @@ func (p *playbackEngine) RemoveTracksFromQueue(idxs []int) {
newQueue = append(newQueue, tr) newQueue = append(newQueue, tr)
} }
} }
p.playQueue = newQueue p.setPlayQueue(newQueue)
p.nowPlayingIdx = newNowPlaying p.nowPlayingIdx = newNowPlaying
if isPlayingTrackRemoved { if isPlayingTrackRemoved {
if newNowPlaying == len(newQueue) { if newNowPlaying == len(newQueue) {