playback: fix crash when song cannot be restored

The index is -1, which is not a valid position to seek through
normally. In this case we should just ignore it.
This commit is contained in:
Alexander Capehart 2024-01-21 19:33:49 -07:00
parent 588b6e9abd
commit b53a96f574
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -774,8 +774,10 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
index
})
if (index > -1) {
// Valid state where something needs to be played, direct the stateholder to apply
// this new state.
val oldStateMirror = stateMirror
if (oldStateMirror.rawQueue != rawQueue) {
logD("Queue changed, must reload player")
stateHolder?.applySavedState(parent, rawQueue, StateAck.NewPlayback)
@ -787,6 +789,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
stateHolder?.seekTo(savedState.positionMs)
stateHolder?.playing(false)
}
}
isInitialized = true
}