Don't hide player controls when touching 'em

This commit is contained in:
Bnyro 2023-01-21 11:13:41 +01:00
parent 87519742da
commit 00c607db49

View File

@ -236,7 +236,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
handler.removeCallbacks(hideControllerRunnable) handler.removeCallbacks(hideControllerRunnable)
// automatically hide the controller after 2 seconds // automatically hide the controller after 2 seconds
handler.postDelayed(hideControllerRunnable, 2000) handler.postDelayed(hideControllerRunnable, AUTO_HIDE_CONTROLLER_DELAY)
super.showController() super.showController()
} }
@ -712,9 +712,22 @@ internal class CustomExoPlayerView(
} }
} }
/**
* Listen for all child touch events
*/
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
// when a control is clicked, restart the countdown to hide the controller
if (isControllerFullyVisible) {
handler.removeCallbacks(hideControllerRunnable)
handler.postDelayed(hideControllerRunnable, AUTO_HIDE_CONTROLLER_DELAY)
}
return super.onInterceptTouchEvent(ev)
}
companion object { companion object {
private const val SUBTITLE_BOTTOM_PADDING_FRACTION = 0.158f private const val SUBTITLE_BOTTOM_PADDING_FRACTION = 0.158f
private const val ANIMATION_DURATION = 100L private const val ANIMATION_DURATION = 100L
private const val AUTO_HIDE_CONTROLLER_DELAY = 2000L
private val LANDSCAPE_MARGIN_HORIZONTAL = (20).toPixel().toInt() private val LANDSCAPE_MARGIN_HORIZONTAL = (20).toPixel().toInt()
} }
} }