Merge pull request #3656 from Bnyro/master

Fix that the player controls don't hide after scrubbing
This commit is contained in:
Bnyro 2023-04-28 11:12:18 +02:00 committed by GitHub
commit 36fa4b54d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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