diff --git a/app/phone/src/main/java/dev/jdtech/jellyfin/utils/PlayerGestureHelper.kt b/app/phone/src/main/java/dev/jdtech/jellyfin/utils/PlayerGestureHelper.kt index 8c11ba3a75..9591abef54 100644 --- a/app/phone/src/main/java/dev/jdtech/jellyfin/utils/PlayerGestureHelper.kt +++ b/app/phone/src/main/java/dev/jdtech/jellyfin/utils/PlayerGestureHelper.kt @@ -55,6 +55,9 @@ class PlayerGestureHelper( private var lastScaleEvent: Long = 0 + private var playbackSpeedIncrease: Float = 2f + private var lastPlaybackSpeed: Float = 0f + private val screenWidth = Resources.getSystem().displayMetrics.widthPixels private val screenHeight = Resources.getSystem().displayMetrics.heightPixels @@ -69,6 +72,18 @@ class PlayerGestureHelper( return true } + @SuppressLint("SetTextI18n") + override fun onLongPress(e: MotionEvent) { + playerView.player?.let { + if (it.isPlaying) { + lastPlaybackSpeed = it.playbackParameters.speed + it.setPlaybackSpeed(playbackSpeedIncrease) + activity.binding.gestureSpeedText.text = playbackSpeedIncrease.toString() + "x" + activity.binding.gestureSpeedLayout.visibility = View.VISIBLE + } + } + } + override fun onDoubleTap(e: MotionEvent): Boolean { // Disables double tap gestures if view is locked if (isControlsLocked) return false @@ -362,6 +377,11 @@ class PlayerGestureHelper( } } } + if (lastPlaybackSpeed > 0 && (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL)) { + playerView.player?.setPlaybackSpeed(lastPlaybackSpeed) + lastPlaybackSpeed = 0f + activity.binding.gestureSpeedLayout.visibility = View.GONE + } } private fun longToTimestamp(duration: Long, noSign: Boolean = false): String { diff --git a/app/phone/src/main/res/layout/activity_player.xml b/app/phone/src/main/res/layout/activity_player.xml index ee2e89772e..c2c1f5b7f8 100644 --- a/app/phone/src/main/res/layout/activity_player.xml +++ b/app/phone/src/main/res/layout/activity_player.xml @@ -113,6 +113,37 @@ tools:ignore="ContentDescription" /> + + + + + + + + + + +