diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 9da3b6f50..2eac2efcc 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -201,7 +201,9 @@ internal class CustomExoPlayerView( cancelHideControllerTask() } - override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {} + override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) { + enqueueHideControllerTask() + } }) setControllerVisibilityListener( @@ -233,6 +235,12 @@ internal class CustomExoPlayerView( ) } + private fun enqueueHideControllerTask() { + handler.postDelayed(AUTO_HIDE_CONTROLLER_DELAY, HIDE_CONTROLLER_TOKEN) { + hideController() + } + } + private fun cancelHideControllerTask() { handler?.removeCallbacksAndMessages(HIDE_CONTROLLER_TOKEN) } @@ -255,9 +263,7 @@ internal class CustomExoPlayerView( // remove the previous callback from the queue to prevent a flashing behavior cancelHideControllerTask() // automatically hide the controller after 2 seconds - handler.postDelayed(AUTO_HIDE_CONTROLLER_DELAY, HIDE_CONTROLLER_TOKEN) { - hideController() - } + enqueueHideControllerTask() super.showController() } @@ -745,9 +751,7 @@ internal class CustomExoPlayerView( // when a control is clicked, restart the countdown to hide the controller if (isControllerFullyVisible) { cancelHideControllerTask() - handler.postDelayed(AUTO_HIDE_CONTROLLER_DELAY, HIDE_CONTROLLER_TOKEN) { - hideController() - } + enqueueHideControllerTask() } return super.onInterceptTouchEvent(ev) }