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