prevent showing loading indicator when reopening the player containing activity

This commit is contained in:
Christian Schabesberger 2024-09-09 22:16:19 +02:00
parent a297a4c08f
commit e965528011
1 changed files with 11 additions and 3 deletions

View File

@ -56,6 +56,7 @@ val VIDEOPLAYER_UI_STATE = "video_player_ui_state"
private const val TAG = "VideoPlayerViewModel"
@UnstableApi
@HiltViewModel
class VideoPlayerViewModelImpl @Inject constructor(
private val savedStateHandle: SavedStateHandle,
@ -183,12 +184,11 @@ class VideoPlayerViewModelImpl @Inject constructor(
}
}
})
}
newPlayer?.let { newPlayer ->
viewModelScope.launch {
newPlayer.playBackMode.collect { newMode ->
val currentMode = mutableUiState.value.uiMode.toPlayMode()
println("gurken mode: $currentMode newMode: $newMode")
if (currentMode != newMode) {
mutableUiState.update {
it.copy(
@ -225,6 +225,14 @@ class VideoPlayerViewModelImpl @Inject constructor(
}
}
}
mutableUiState.update {
it.copy(
playing = newPlayer.internalPlayer.isPlaying,
isLoading = !newPlayer.internalPlayer.isPlaying
&& newPlayer.internalPlayer.isLoading
)
}
}
}