mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Seek bar uses same skip intervals
This commit is contained in:
parent
8dba561376
commit
d1e9561eae
2 changed files with 12 additions and 5 deletions
|
|
@ -156,6 +156,8 @@ fun PlaybackControls(
|
||||||
interactionSource = seekBarInteractionSource,
|
interactionSource = seekBarInteractionSource,
|
||||||
isEnabled = seekEnabled,
|
isEnabled = seekEnabled,
|
||||||
intervals = seekBarIntervals,
|
intervals = seekBarIntervals,
|
||||||
|
seekBack = seekBack,
|
||||||
|
seekForward = seekForward,
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.padding(vertical = 0.dp)
|
.padding(vertical = 0.dp)
|
||||||
|
|
@ -211,6 +213,8 @@ fun SeekBar(
|
||||||
intervals: Int,
|
intervals: Int,
|
||||||
controllerViewState: ControllerViewState,
|
controllerViewState: ControllerViewState,
|
||||||
onSeekProgress: (Long) -> Unit,
|
onSeekProgress: (Long) -> Unit,
|
||||||
|
seekBack: Duration,
|
||||||
|
seekForward: Duration,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
) {
|
) {
|
||||||
|
|
@ -241,6 +245,8 @@ fun SeekBar(
|
||||||
interactionSource = interactionSource,
|
interactionSource = interactionSource,
|
||||||
enabled = isEnabled,
|
enabled = isEnabled,
|
||||||
durationMs = player.contentDuration,
|
durationMs = player.contentDuration,
|
||||||
|
seekBack = seekBack,
|
||||||
|
seekForward = seekForward,
|
||||||
)
|
)
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.MaterialTheme
|
import androidx.tv.material3.MaterialTheme
|
||||||
import com.github.damontecres.dolphin.ui.handleDPadKeyEvents
|
import com.github.damontecres.dolphin.ui.handleDPadKeyEvents
|
||||||
import kotlinx.coroutines.FlowPreview
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SteppedSeekBarImpl(
|
fun SteppedSeekBarImpl(
|
||||||
|
|
@ -105,6 +105,8 @@ fun IntervalSeekBarImpl(
|
||||||
bufferedProgress: Float,
|
bufferedProgress: Float,
|
||||||
onSeek: (Long) -> Unit,
|
onSeek: (Long) -> Unit,
|
||||||
controllerViewState: ControllerViewState,
|
controllerViewState: ControllerViewState,
|
||||||
|
seekBack: Duration,
|
||||||
|
seekForward: Duration,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
|
|
@ -120,21 +122,20 @@ fun IntervalSeekBarImpl(
|
||||||
if (!isFocused) hasSeeked = false
|
if (!isFocused) hasSeeked = false
|
||||||
}
|
}
|
||||||
|
|
||||||
val offset = 30.seconds.inWholeMilliseconds
|
|
||||||
|
|
||||||
SeekBarDisplay(
|
SeekBarDisplay(
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
progress = (progressToUse.toDouble() / durationMs).toFloat(),
|
progress = (progressToUse.toDouble() / durationMs).toFloat(),
|
||||||
bufferedProgress = bufferedProgress,
|
bufferedProgress = bufferedProgress,
|
||||||
onLeft = {
|
onLeft = {
|
||||||
controllerViewState.pulseControls()
|
controllerViewState.pulseControls()
|
||||||
seekPositionMs = (progressToUse - offset).coerceAtLeast(0L)
|
seekPositionMs = (progressToUse - seekBack.inWholeMilliseconds).coerceAtLeast(0L)
|
||||||
hasSeeked = true
|
hasSeeked = true
|
||||||
onSeek(seekPositionMs)
|
onSeek(seekPositionMs)
|
||||||
},
|
},
|
||||||
onRight = {
|
onRight = {
|
||||||
controllerViewState.pulseControls()
|
controllerViewState.pulseControls()
|
||||||
seekPositionMs = (progressToUse + offset).coerceAtMost(durationMs)
|
seekPositionMs =
|
||||||
|
(progressToUse + seekForward.inWholeMilliseconds).coerceAtMost(durationMs)
|
||||||
hasSeeked = true
|
hasSeeked = true
|
||||||
onSeek(seekPositionMs)
|
onSeek(seekPositionMs)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue