Skip to content

Commit

Permalink
feat(player): haptic feedback when long pressing for 2x
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahmehiz committed Jul 20, 2024
1 parent 64ccff8 commit 6c97f9c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 }
Expand Down

0 comments on commit 6c97f9c

Please sign in to comment.