tasker: fix player main thread bugs on restore
This commit is contained in:
parent
27e378ae2a
commit
cc7f9ba539
1 changed files with 6 additions and 6 deletions
|
@ -164,17 +164,17 @@ class ExoPlaybackStateHolder(
|
||||||
logD("Restoring playback state")
|
logD("Restoring playback state")
|
||||||
restoreScope.launch {
|
restoreScope.launch {
|
||||||
val state = persistenceRepository.readState()
|
val state = persistenceRepository.readState()
|
||||||
if (state != null) {
|
withContext(Dispatchers.Main) {
|
||||||
// Apply the saved state on the main thread to prevent code expecting
|
if (state != null) {
|
||||||
// state updates on the main thread from crashing.
|
// Apply the saved state on the main thread to prevent code expecting
|
||||||
withContext(Dispatchers.Main) {
|
// state updates on the main thread from crashing.
|
||||||
playbackManager.applySavedState(state, false)
|
playbackManager.applySavedState(state, false)
|
||||||
if (action.play) {
|
if (action.play) {
|
||||||
playbackManager.playing(true)
|
playbackManager.playing(true)
|
||||||
}
|
}
|
||||||
|
} else if (action.fallback != null) {
|
||||||
|
playbackManager.playDeferred(action.fallback)
|
||||||
}
|
}
|
||||||
} else if (action.fallback != null) {
|
|
||||||
playbackManager.playDeferred(action.fallback)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue