From 6aa53d6cfe2cfc424f47f599ae34d2bea49dcafa Mon Sep 17 00:00:00 2001 From: tk <60766886+Tim-Kaiser@users.noreply.github.com> Date: Sun, 5 Apr 2026 18:53:30 +0200 Subject: [PATCH] Merge pull request #896 from Tim-Kaiser/ISSUE-895 Fix #895: Fix crash on track change and scrobble --- backend/playbackengine.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/playbackengine.go b/backend/playbackengine.go index 2b100cf..a84022b 100644 --- a/backend/playbackengine.go +++ b/backend/playbackengine.go @@ -262,6 +262,7 @@ func (p *playbackEngine) getPlayQueueLength() int { } func (p *playbackEngine) clearPlayQueue() { + p.checkScrobble() p.player.Stop(false) p.nowPlayingIdx = -1 p.playQueue = nil @@ -576,12 +577,13 @@ func (p *playbackEngine) LoadItems(items []mediaprovider.MediaItem, insertQueueM return p.doLoaditems(newItems, insertQueueMode, shuffle) } -// Load items into the play queue. -// If replacing the current queue (!appendToQueue), playback will be stopped. +// Load items into the play queue and play the track at idx. +// Replaces the playQueue, shuffledPlayQueue, or both func (p *playbackEngine) LoadItemsAndPlayAtIdx(items []mediaprovider.MediaItem, shuffle bool, idx int) error { newItems := deepCopyMediaItemSlice(items) if p.shuffle || shuffle { + p.clearPlayQueue() rand.Shuffle(len(newItems), func(i, j int) { newItems[i], newItems[j] = newItems[j], newItems[i] })