fix: long press fixes
Disable when controls are locked Disable when more than 1 pointer
This commit is contained in:
parent
42df641c03
commit
782f736a8a
1 changed files with 11 additions and 1 deletions
|
@ -61,6 +61,8 @@ class PlayerGestureHelper(
|
||||||
private val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
private val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
||||||
private val screenHeight = Resources.getSystem().displayMetrics.heightPixels
|
private val screenHeight = Resources.getSystem().displayMetrics.heightPixels
|
||||||
|
|
||||||
|
private var currentNumberOfPointers: Int = 0
|
||||||
|
|
||||||
private val tapGestureDetector = GestureDetector(
|
private val tapGestureDetector = GestureDetector(
|
||||||
playerView.context,
|
playerView.context,
|
||||||
object : GestureDetector.SimpleOnGestureListener() {
|
object : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@ -74,6 +76,12 @@ class PlayerGestureHelper(
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onLongPress(e: MotionEvent) {
|
override fun onLongPress(e: MotionEvent) {
|
||||||
|
// Disables long press gesture if view is locked
|
||||||
|
if (isControlsLocked) return
|
||||||
|
|
||||||
|
// Stop long press gesture when more than 1 pointer
|
||||||
|
if (currentNumberOfPointers > 1) return
|
||||||
|
|
||||||
playerView.player?.let {
|
playerView.player?.let {
|
||||||
if (it.isPlaying) {
|
if (it.isPlaying) {
|
||||||
lastPlaybackSpeed = it.playbackParameters.speed
|
lastPlaybackSpeed = it.playbackParameters.speed
|
||||||
|
@ -350,7 +358,7 @@ class PlayerGestureHelper(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun releaseAction(event: MotionEvent) {
|
private fun releaseAction(event: MotionEvent) {
|
||||||
if (event.action == MotionEvent.ACTION_UP) {
|
if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) {
|
||||||
activity.binding.gestureVolumeLayout.apply {
|
activity.binding.gestureVolumeLayout.apply {
|
||||||
if (visibility == View.VISIBLE) {
|
if (visibility == View.VISIBLE) {
|
||||||
removeCallbacks(hideGestureVolumeIndicatorOverlayAction)
|
removeCallbacks(hideGestureVolumeIndicatorOverlayAction)
|
||||||
|
@ -377,6 +385,7 @@ class PlayerGestureHelper(
|
||||||
swipeGestureValueTrackerProgress = -1L
|
swipeGestureValueTrackerProgress = -1L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
currentNumberOfPointers = 0
|
||||||
}
|
}
|
||||||
if (lastPlaybackSpeed > 0 && (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL)) {
|
if (lastPlaybackSpeed > 0 && (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL)) {
|
||||||
playerView.player?.setPlaybackSpeed(lastPlaybackSpeed)
|
playerView.player?.setPlaybackSpeed(lastPlaybackSpeed)
|
||||||
|
@ -424,6 +433,7 @@ class PlayerGestureHelper(
|
||||||
@Suppress("ClickableViewAccessibility")
|
@Suppress("ClickableViewAccessibility")
|
||||||
playerView.setOnTouchListener { _, event ->
|
playerView.setOnTouchListener { _, event ->
|
||||||
if (playerView.useController) {
|
if (playerView.useController) {
|
||||||
|
currentNumberOfPointers = event.pointerCount
|
||||||
when (event.pointerCount) {
|
when (event.pointerCount) {
|
||||||
1 -> {
|
1 -> {
|
||||||
tapGestureDetector.onTouchEvent(event)
|
tapGestureDetector.onTouchEvent(event)
|
||||||
|
|
Loading…
Reference in a new issue