Seek bar uses same skip intervals

This commit is contained in:
Damontecres 2025-10-14 14:19:59 -04:00
parent 8dba561376
commit d1e9561eae
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View file

@ -156,6 +156,8 @@ fun PlaybackControls(
interactionSource = seekBarInteractionSource,
isEnabled = seekEnabled,
intervals = seekBarIntervals,
seekBack = seekBack,
seekForward = seekForward,
modifier =
Modifier
.padding(vertical = 0.dp)
@ -211,6 +213,8 @@ fun SeekBar(
intervals: Int,
controllerViewState: ControllerViewState,
onSeekProgress: (Long) -> Unit,
seekBack: Duration,
seekForward: Duration,
modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
) {
@ -241,6 +245,8 @@ fun SeekBar(
interactionSource = interactionSource,
enabled = isEnabled,
durationMs = player.contentDuration,
seekBack = seekBack,
seekForward = seekForward,
)
Row(
modifier = Modifier.fillMaxWidth(),

View file

@ -48,7 +48,7 @@ import androidx.compose.ui.unit.dp
import androidx.tv.material3.MaterialTheme
import com.github.damontecres.dolphin.ui.handleDPadKeyEvents
import kotlinx.coroutines.FlowPreview
import kotlin.time.Duration.Companion.seconds
import kotlin.time.Duration
@Composable
fun SteppedSeekBarImpl(
@ -105,6 +105,8 @@ fun IntervalSeekBarImpl(
bufferedProgress: Float,
onSeek: (Long) -> Unit,
controllerViewState: ControllerViewState,
seekBack: Duration,
seekForward: Duration,
modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
enabled: Boolean = true,
@ -120,21 +122,20 @@ fun IntervalSeekBarImpl(
if (!isFocused) hasSeeked = false
}
val offset = 30.seconds.inWholeMilliseconds
SeekBarDisplay(
enabled = enabled,
progress = (progressToUse.toDouble() / durationMs).toFloat(),
bufferedProgress = bufferedProgress,
onLeft = {
controllerViewState.pulseControls()
seekPositionMs = (progressToUse - offset).coerceAtLeast(0L)
seekPositionMs = (progressToUse - seekBack.inWholeMilliseconds).coerceAtLeast(0L)
hasSeeked = true
onSeek(seekPositionMs)
},
onRight = {
controllerViewState.pulseControls()
seekPositionMs = (progressToUse + offset).coerceAtMost(durationMs)
seekPositionMs =
(progressToUse + seekForward.inWholeMilliseconds).coerceAtMost(durationMs)
hasSeeked = true
onSeek(seekPositionMs)
},