From 9f75cd138811fda4f677ebc4d7cdb6ca47cc7ff7 Mon Sep 17 00:00:00 2001 From: AbdallahMehiz Date: Tue, 10 Sep 2024 19:43:48 +0100 Subject: [PATCH] fix: hold for 2x speed setting not having any effect closes #67 --- .../live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt index 7c27d61..c13d608 100644 --- a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt +++ b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt @@ -86,6 +86,7 @@ fun GestureHandler(modifier: Modifier = Modifier) { val doubleTapToPause by playerPreferences.doubleTapToPause.collectAsState() val doubleTapToSeek by playerPreferences.doubleTapToSeek.collectAsState() val doubleTapToSeekDuration by playerPreferences.doubleTapToSeekDuration.collectAsState() + val doubleSpeedGesture by playerPreferences.holdForDoubleSpeed.collectAsState() val brightnessGesture = playerPreferences.brightnessGesture.get() val volumeGesture by playerPreferences.volumeGesture.collectAsState() val seekGesture by playerPreferences.horizontalSeekGesture.collectAsState() @@ -194,7 +195,7 @@ fun GestureHandler(modifier: Modifier = Modifier) { interactionSource.emit(PressInteraction.Release(press)) }, onLongPress = { - if (areControlsLocked) return@detectTapGestures + if (!doubleSpeedGesture || areControlsLocked) return@detectTapGestures if (!isLongPressing && !viewModel.paused.value) { originalSpeed = viewModel.playbackSpeed.value haptics.performHapticFeedback(HapticFeedbackType.LongPress) @@ -227,7 +228,7 @@ fun GestureHandler(modifier: Modifier = Modifier) { if (position >= duration && dragAmount > 0) return@detectHorizontalDragGestures calculateNewHorizontalGestureValue(startingPosition, startingX, change.position.x, 0.15f).let { viewModel.gestureSeekAmount.update { _ -> - Pair(startingPosition, it - startingPosition) + Pair(startingPosition, (it - startingPosition).coerceIn(0, (duration - startingPosition).toInt())) } viewModel.seekTo(it, preciseSeeking) }