diff --git a/backend/playbackengine.go b/backend/playbackengine.go index cb136c5..8179db2 100644 --- a/backend/playbackengine.go +++ b/backend/playbackengine.go @@ -248,8 +248,11 @@ func (p *playbackEngine) getPlayQueueItemAt(idx int) mediaprovider.MediaItem { return p.playQueue[idx] } -// rename to GetPlayQueueExternal -func (p *playbackEngine) GetPlayQueue() []mediaprovider.MediaItem { +func (p *playbackEngine) getPlayQueue() []mediaprovider.MediaItem { + return p.playQueue +} + +func (p *playbackEngine) GetPlayQueueDeepCopy() []mediaprovider.MediaItem { return deepCopyMediaItemSlice(p.playQueue) } @@ -477,7 +480,7 @@ func (p *playbackEngine) StopAndClearPlayQueue() { // Any time the user changes the favorite status of a track elsewhere in the app, // this should be called to ensure the in-memory track model is updated. func (p *playbackEngine) OnTrackFavoriteStatusChanged(id string, fav bool) { - if item := sharedutil.FindMediaItemByID(id, p.playQueue); item != nil { + if item := sharedutil.FindMediaItemByID(id, p.getPlayQueue()); item != nil { if tr, ok := item.(*mediaprovider.Track); ok { tr.Favorite = fav } @@ -487,7 +490,7 @@ func (p *playbackEngine) OnTrackFavoriteStatusChanged(id string, fav bool) { // Any time the user changes the rating of a track elsewhere in the app, // this should be called to ensure the in-memory track model is updated. func (p *playbackEngine) OnTrackRatingChanged(id string, rating int) { - if item := sharedutil.FindMediaItemByID(id, p.playQueue); item != nil { + if item := sharedutil.FindMediaItemByID(id, p.getPlayQueue()); item != nil { if tr, ok := item.(*mediaprovider.Track); ok { tr.Rating = rating } @@ -530,7 +533,7 @@ func (p *playbackEngine) RemoveTracksFromQueue(idxs []int) { isNextPlayingTrackremoved := false nowPlaying := p.NowPlayingIndex() newNowPlaying := nowPlaying - for i, tr := range p.playQueue { + for i, tr := range p.getPlayQueue() { if _, ok := idxSet[i]; ok { if i < nowPlaying { // if removing a track earlier than the currently playing one (if any), diff --git a/backend/playbackmanager.go b/backend/playbackmanager.go index cf82346..f6f3376 100644 --- a/backend/playbackmanager.go +++ b/backend/playbackmanager.go @@ -557,7 +557,7 @@ func (p *PlaybackManager) fetchAndPlayTracks(fetchFn func() ([]*mediaprovider.Tr } func (p *PlaybackManager) GetPlayQueue() []mediaprovider.MediaItem { - return p.engine.GetPlayQueue() + return p.engine.GetPlayQueueDeepCopy() } // Any time the user changes the favorite status of a track elsewhere in the app,