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:
parent
588b6e9abd
commit
b53a96f574
1 changed files with 14 additions and 11 deletions
|
@ -774,18 +774,21 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||||
index
|
index
|
||||||
})
|
})
|
||||||
|
|
||||||
val oldStateMirror = stateMirror
|
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)
|
||||||
|
stateHolder?.playing(false)
|
||||||
|
}
|
||||||
|
|
||||||
if (oldStateMirror.rawQueue != rawQueue) {
|
if (oldStateMirror.progression.calculateElapsedPositionMs() != savedState.positionMs) {
|
||||||
logD("Queue changed, must reload player")
|
logD("Seeking to saved position ${savedState.positionMs}ms")
|
||||||
stateHolder?.applySavedState(parent, rawQueue, StateAck.NewPlayback)
|
stateHolder?.seekTo(savedState.positionMs)
|
||||||
stateHolder?.playing(false)
|
stateHolder?.playing(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldStateMirror.progression.calculateElapsedPositionMs() != savedState.positionMs) {
|
|
||||||
logD("Seeking to saved position ${savedState.positionMs}ms")
|
|
||||||
stateHolder?.seekTo(savedState.positionMs)
|
|
||||||
stateHolder?.playing(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
|
|
Loading…
Reference in a new issue