getPlayQueue func
This commit is contained in:
@@ -248,8 +248,11 @@ func (p *playbackEngine) getPlayQueueItemAt(idx int) mediaprovider.MediaItem {
|
|||||||
return p.playQueue[idx]
|
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)
|
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,
|
// 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.
|
// this should be called to ensure the in-memory track model is updated.
|
||||||
func (p *playbackEngine) OnTrackFavoriteStatusChanged(id string, fav bool) {
|
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 {
|
if tr, ok := item.(*mediaprovider.Track); ok {
|
||||||
tr.Favorite = fav
|
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,
|
// 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.
|
// this should be called to ensure the in-memory track model is updated.
|
||||||
func (p *playbackEngine) OnTrackRatingChanged(id string, rating int) {
|
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 {
|
if tr, ok := item.(*mediaprovider.Track); ok {
|
||||||
tr.Rating = rating
|
tr.Rating = rating
|
||||||
}
|
}
|
||||||
@@ -530,7 +533,7 @@ func (p *playbackEngine) RemoveTracksFromQueue(idxs []int) {
|
|||||||
isNextPlayingTrackremoved := false
|
isNextPlayingTrackremoved := false
|
||||||
nowPlaying := p.NowPlayingIndex()
|
nowPlaying := p.NowPlayingIndex()
|
||||||
newNowPlaying := nowPlaying
|
newNowPlaying := nowPlaying
|
||||||
for i, tr := range p.playQueue {
|
for i, tr := range p.getPlayQueue() {
|
||||||
if _, ok := idxSet[i]; ok {
|
if _, ok := idxSet[i]; ok {
|
||||||
if i < nowPlaying {
|
if i < nowPlaying {
|
||||||
// if removing a track earlier than the currently playing one (if any),
|
// if removing a track earlier than the currently playing one (if any),
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ func (p *PlaybackManager) fetchAndPlayTracks(fetchFn func() ([]*mediaprovider.Tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlaybackManager) GetPlayQueue() []mediaprovider.MediaItem {
|
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,
|
// Any time the user changes the favorite status of a track elsewhere in the app,
|
||||||
|
|||||||
Reference in New Issue
Block a user