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()
}
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)
}