mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
feature: add resume/pause functionality to PlayerGesturesLayer and update seek duration
This commit is contained in:
@@ -89,8 +89,9 @@ fun PlayerScreen(
|
||||
PlayerGesturesLayer(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
onTap = { viewModel.toggleControlsVisibility() },
|
||||
onSeekForward = { viewModel.seekBy(10_000) },
|
||||
onSeekForward = { viewModel.seekBy(30_000) },
|
||||
onSeekBackward = { viewModel.seekBy(-10_000) },
|
||||
onResumePause = {viewModel.togglePlayPause()},
|
||||
onVerticalDragLeft = { delta ->
|
||||
val diff = (-delta / 800f)
|
||||
brightness = (brightness + diff).coerceIn(0f, 1f)
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.compose.ui.input.pointer.pointerInput
|
||||
fun PlayerGesturesLayer(
|
||||
modifier: Modifier = Modifier,
|
||||
onTap: () -> Unit,
|
||||
onResumePause: () -> Unit,
|
||||
onSeekForward: () -> Unit,
|
||||
onSeekBackward: () -> Unit,
|
||||
onVerticalDragLeft: (delta: Float) -> Unit,
|
||||
@@ -24,9 +25,14 @@ fun PlayerGesturesLayer(
|
||||
detectTapGestures(
|
||||
onTap = { onTap() },
|
||||
onDoubleTap = { offset ->
|
||||
val half = size.width / 2
|
||||
if (offset.x < half) {
|
||||
// TODO extract it into an enum
|
||||
val screenWidth = size.width
|
||||
val oneThird = screenWidth / 3
|
||||
val secondThird = oneThird * 2
|
||||
if (offset.x < oneThird) {
|
||||
onSeekBackward()
|
||||
} else if (offset.x >= oneThird && offset.x <= secondThird) {
|
||||
onResumePause()
|
||||
} else {
|
||||
onSeekForward()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user