getPlayQueue func

This commit is contained in:
Siiiiinth
2026-01-24 23:32:02 +01:00
parent 42d3ee4973
commit 902e6e3dc8
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -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),
+1 -1
View File
@@ -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,