clearPlayQueue func

This commit is contained in:
Siiiiinth
2026-01-24 21:43:29 +01:00
parent ba62f028b0
commit 54844a0e2b
+11 -3
View File
@@ -225,9 +225,17 @@ func (p *playbackEngine) SetPlayer(pl player.BasePlayer) error {
// Interface functions for interacting with the play queue
func (p *playbackEngine) getPlayQueueLength() int {
if p.shuffle {
return len(p.playQueueShuffle)
}
return len(p.playQueue)
}
func (p *playbackEngine) clearPlayQueue() {
p.playQueue = nil
p.playQueueShuffle = nil
}
func (p *playbackEngine) PlayTrackAt(idx int) error {
return p.playTrackAt(idx, 0)
}
@@ -395,7 +403,7 @@ func (p *playbackEngine) doLoaditems(items []mediaprovider.MediaItem, insertQueu
if insertQueueMode == Replace {
p.player.Stop(false)
p.nowPlayingIdx = -1
p.playQueue = nil
p.clearPlayQueue()
}
if nextChanged := len(items) > 0 && (insertQueueMode != Append || (p.nowPlayingIdx == p.getPlayQueueLength()-1)); nextChanged {
defer p.handleNextTrackUpdated()
@@ -419,7 +427,7 @@ func (p *playbackEngine) LoadRadioStation(radio *mediaprovider.RadioStation, ins
if insertMode == Replace {
p.player.Stop(false)
p.nowPlayingIdx = -1
p.playQueue = nil
p.clearPlayQueue()
}
if nextChanged := insertMode == InsertNext || (insertMode == Append && p.nowPlayingIdx == p.getPlayQueueLength()-1); nextChanged {
p.handleNextTrackUpdated()
@@ -442,7 +450,7 @@ func (p *playbackEngine) LoadRadioStation(radio *mediaprovider.RadioStation, ins
func (p *playbackEngine) StopAndClearPlayQueue() {
changed := p.getPlayQueueLength() > 0
p.player.Stop(false)
p.playQueue = nil
p.clearPlayQueue()
p.nowPlayingIdx = -1
if changed {
p.invokeNoArgCallbacks(p.onQueueChange)