don't crash with index out of range when removing radios from saved play queue
This commit is contained in:
+1
-1
@@ -378,7 +378,7 @@ func (a *App) LoadSavedPlayQueue() error {
|
||||
if err := a.PlaybackManager.LoadTracks(queue.Tracks, Replace, false); err != nil {
|
||||
return err
|
||||
}
|
||||
if queue.TrackIndex >= 0 {
|
||||
if queue.TrackIndex >= 0 && queue.TrackIndex < len(queue.Tracks) {
|
||||
// TODO: This isn't ideal but doesn't seem to cause an audible play-for-a-split-second artifact
|
||||
a.PlaybackManager.PlayTrackAt(queue.TrackIndex)
|
||||
a.PlaybackManager.Pause()
|
||||
|
||||
@@ -36,6 +36,13 @@ func SavePlayQueue(serverID string, pm *PlaybackManager, filepath string, server
|
||||
trackIDs = append(trackIDs, item.Metadata().ID)
|
||||
}
|
||||
}
|
||||
if l := len(trackIDs); trackIdx >= l {
|
||||
if l == 0 {
|
||||
trackIdx = 0
|
||||
} else {
|
||||
trackIdx = l - 1
|
||||
}
|
||||
}
|
||||
|
||||
saved := serializedSavedPlayQueue{
|
||||
ServerID: serverID,
|
||||
|
||||
Reference in New Issue
Block a user