diff --git a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/PlayerScreen.kt b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/PlayerScreen.kt index d7c43c9916..1dbe3a1546 100644 --- a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/PlayerScreen.kt +++ b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/PlayerScreen.kt @@ -238,6 +238,8 @@ fun VideoPlayerControls( onSeek = { player.seekTo(player.duration.times(it).toLong()) }, contentProgress = contentCurrentPosition.milliseconds, contentDuration = player.duration.milliseconds, + seekBackIncrement = player.seekBackIncrement.milliseconds, + seekForwardIncrement = player.seekForwardIncrement.milliseconds, ) }, mediaActions = { diff --git a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeekBar.kt b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeekBar.kt index 33b5c60c4f..f3e2613e59 100644 --- a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeekBar.kt +++ b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeekBar.kt @@ -24,18 +24,20 @@ import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.media3.common.C import androidx.tv.material3.MaterialTheme import dev.jdtech.jellyfin.ui.theme.FindroidTheme import dev.jdtech.jellyfin.utils.handleDPadKeyEvents import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds +import kotlin.time.Duration.Companion.milliseconds @OptIn(ExperimentalComposeUiApi::class) @Composable fun VideoPlayerSeekBar( contentProgress: Duration, contentDuration: Duration, - seekProgressStep: Duration, + seekBackIncrement: Duration, + seekForwardIncrement: Duration, onSeek: (seekProgress: Float) -> Unit, state: VideoPlayerState, ) { @@ -80,14 +82,14 @@ fun VideoPlayerSeekBar( }, onLeft = { if (isSelected) { - seekContentProgress = (seekContentProgress - seekProgressStep).coerceAtLeast(Duration.ZERO) + seekContentProgress = (seekContentProgress - seekBackIncrement).coerceAtLeast(Duration.ZERO) } else { focusManager.moveFocus(FocusDirection.Left) } }, onRight = { if (isSelected) { - seekContentProgress = (seekContentProgress + seekProgressStep).coerceAtMost(contentDuration) + seekContentProgress = (seekContentProgress + seekForwardIncrement).coerceAtMost(contentDuration) } else { focusManager.moveFocus(FocusDirection.Right) } @@ -131,7 +133,8 @@ fun VideoPlayerSeekBarPreview() { VideoPlayerSeekBar( contentProgress = Duration.parse("7m 51s"), contentDuration = Duration.parse("23m 40s"), - seekProgressStep = 30.seconds, + seekBackIncrement = C.DEFAULT_SEEK_BACK_INCREMENT_MS.milliseconds, + seekForwardIncrement = C.DEFAULT_SEEK_FORWARD_INCREMENT_MS.milliseconds, onSeek = {}, state = rememberVideoPlayerState(), ) diff --git a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeeker.kt b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeeker.kt index e45062b108..b1df7fc9e5 100644 --- a/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeeker.kt +++ b/app/tv/src/main/java/dev/jdtech/jellyfin/ui/components/player/VideoPlayerSeeker.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview +import androidx.media3.common.C import androidx.tv.material3.Icon import androidx.tv.material3.IconButton import androidx.tv.material3.MaterialTheme @@ -22,7 +23,7 @@ import androidx.tv.material3.Text import dev.jdtech.jellyfin.ui.theme.FindroidTheme import dev.jdtech.jellyfin.ui.theme.spacings import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds +import kotlin.time.Duration.Companion.milliseconds import dev.jdtech.jellyfin.core.R as CoreR @Composable @@ -34,6 +35,8 @@ fun VideoPlayerSeeker( onSeek: (Float) -> Unit, contentProgress: Duration, contentDuration: Duration, + seekBackIncrement: Duration, + seekForwardIncrement: Duration, ) { val contentProgressString = contentProgress.toComponents { h, m, s, _ -> @@ -94,8 +97,8 @@ fun VideoPlayerSeeker( VideoPlayerSeekBar( contentProgress = contentProgress, contentDuration = contentDuration, - // TODO: pass param from setting cache - seekProgressStep = 30.seconds, + seekBackIncrement = seekBackIncrement, + seekForwardIncrement = seekForwardIncrement, onSeek = onSeek, state = state, ) @@ -115,6 +118,8 @@ private fun VideoPlayerSeekerPreview() { onSeek = {}, contentProgress = Duration.parse("7m 51s"), contentDuration = Duration.parse("23m 40s"), + seekBackIncrement = C.DEFAULT_SEEK_BACK_INCREMENT_MS.milliseconds, + seekForwardIncrement = C.DEFAULT_SEEK_FORWARD_INCREMENT_MS.milliseconds, ) } }