fix issue that fast seek indicator does not disabpear on fullscreen switch

This commit is contained in:
Christian Schabesberger 2024-08-07 19:01:16 +02:00
parent a5c9baa26d
commit 6ff8f7c1e9
3 changed files with 12 additions and 9 deletions

View File

@ -49,7 +49,7 @@ interface VideoPlayerViewModel {
fun seekingFinished() fun seekingFinished()
fun embeddedDraggedDown(offset: Float) fun embeddedDraggedDown(offset: Float)
fun fastSeek(count: Int) fun fastSeek(count: Int)
fun fastSeekFinished() fun finishFastSeek()
interface Listener { interface Listener {
fun onFullscreenToggle(isFullscreen: Boolean) {} fun onFullscreenToggle(isFullscreen: Boolean) {}

View File

@ -279,8 +279,9 @@ class VideoPlayerViewModelImpl @Inject constructor(
} }
} }
override fun fastSeekFinished() { override fun finishFastSeek() {
val fastSeekAmount = mutableUiState.value.fastseekSeconds val fastSeekAmount = mutableUiState.value.fastseekSeconds
if (fastSeekAmount != 0) {
Log.d(TAG, "$fastSeekAmount") Log.d(TAG, "$fastSeekAmount")
newPlayer?.currentPosition = (newPlayer?.currentPosition ?: 0) + (fastSeekAmount * 1000) newPlayer?.currentPosition = (newPlayer?.currentPosition ?: 0) + (fastSeekAmount * 1000)
@ -288,10 +289,12 @@ class VideoPlayerViewModelImpl @Inject constructor(
it.copy(fastseekSeconds = 0) it.copy(fastseekSeconds = 0)
} }
} }
}
override fun switchToEmbeddedView() { override fun switchToEmbeddedView() {
callbackListeners.forEach { it?.onFullscreenToggle(false) } callbackListeners.forEach { it?.onFullscreenToggle(false) }
uiVisibilityJob?.cancel() uiVisibilityJob?.cancel()
finishFastSeek()
mutableUiState.update { mutableUiState.update {
it.copy(fullscreen = false, uiVissible = false) it.copy(fullscreen = false, uiVissible = false)
} }
@ -300,7 +303,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
override fun switchToFullscreen() { override fun switchToFullscreen() {
callbackListeners.forEach { it?.onFullscreenToggle(true) } callbackListeners.forEach { it?.onFullscreenToggle(true) }
uiVisibilityJob?.cancel() uiVisibilityJob?.cancel()
finishFastSeek()
mutableUiState.update { mutableUiState.update {
it.copy(fullscreen = true, uiVissible = false) it.copy(fullscreen = true, uiVissible = false)
} }
@ -371,7 +374,7 @@ class VideoPlayerViewModelImpl @Inject constructor(
println("dummy impl") println("dummy impl")
} }
override fun fastSeekFinished() { override fun finishFastSeek() {
println("dummy impl") println("dummy impl")
} }

View File

@ -165,7 +165,7 @@ fun VideoPlayerUI(
seekingFinished = viewModel::seekingFinished, seekingFinished = viewModel::seekingFinished,
embeddedDraggedDownBy = viewModel::embeddedDraggedDown, embeddedDraggedDownBy = viewModel::embeddedDraggedDown,
fastSeek = viewModel::fastSeek, fastSeek = viewModel::fastSeek,
finishFastSeek = viewModel::fastSeekFinished finishFastSeek = viewModel::finishFastSeek
) )
} }
} }