only show loading cycle when not playing

This commit is contained in:
Christian Schabesberger 2024-09-04 11:08:05 +02:00
parent 38ea5560b6
commit 26cb3cf749
1 changed files with 6 additions and 4 deletions

View File

@ -142,7 +142,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
super.onIsPlayingChanged(isPlaying)
Log.d(TAG, "Playing state changed. Is Playing: $isPlaying")
mutableUiState.update {
it.copy(playing = isPlaying)
it.copy(playing = isPlaying, isLoading = false)
}
}
@ -155,8 +155,10 @@ class VideoPlayerViewModelImpl @Inject constructor(
// TODO: This is not correctly applicable for loading indicator
override fun onIsLoadingChanged(isLoading: Boolean) {
super.onIsLoadingChanged(isLoading)
mutableUiState.update {
it.copy(isLoading = isLoading)
if(!player.isPlaying) {
mutableUiState.update {
it.copy(isLoading = isLoading)
}
}
}
@ -263,7 +265,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
private fun resetHideUiDelayedJob() {
uiVisibilityJob?.cancel()
uiVisibilityJob = viewModelScope.launch {
delay(4000)
delay(2000)
hideUi()
}
}