From 6c97f9c406dc6a6e1c1f0e43a84201ae5d5c79c4 Mon Sep 17 00:00:00 2001 From: AbdallahMehiz Date: Sat, 20 Jul 2024 13:59:02 +0100 Subject: [PATCH] feat(player): haptic feedback when long pressing for 2x --- .../live/mehiz/mpvkt/ui/player/controls/GestureHandler.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 4e0bfea..a436e32 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 @@ -31,7 +31,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.unit.IntSize import androidx.compose.ui.viewinterop.AndroidView import `is`.xyz.mpv.MPVLib @@ -100,6 +102,7 @@ fun GestureHandler( var isLongPressing by remember { mutableStateOf(false) } val currentVolume by viewModel.currentVolume.collectAsState() val currentBrightness by viewModel.currentBrightness.collectAsState() + val haptics = LocalHapticFeedback.current Box( modifier = modifier .fillMaxSize() @@ -140,6 +143,7 @@ fun GestureHandler( }, onLongPress = { if (!isLongPressing && !viewModel.paused.value) { + haptics.performHapticFeedback(HapticFeedbackType.LongPress) isLongPressing = true MPVLib.setPropertyDouble("speed", 2.0) viewModel.playerUpdate.update { PlayerUpdates.DoubleSpeed }