fix(tv): focus segment skip button

This commit is contained in:
2026-05-01 12:29:01 +02:00
parent 93070ba23f
commit 7401f986c6

View File

@@ -181,12 +181,16 @@ fun TvPlayerScreen(
} }
} }
LaunchedEffect(controlsVisible, controlsAutoHideBlocked) { LaunchedEffect(
controlsVisible,
controlsAutoHideBlocked,
uiState.activeSkippableSegmentEndMs
) {
if (controlsAutoHideBlocked) return@LaunchedEffect if (controlsAutoHideBlocked) return@LaunchedEffect
if (controlsVisible) { if (controlsVisible) {
controlsFocusRequester.requestFocus() controlsFocusRequester.requestFocus()
} else { } else {
uiState.activeSkippableSegmentEndMs?.let { if (uiState.activeSkippableSegmentEndMs != null) {
skipButtonFocusRequester.requestFocus() skipButtonFocusRequester.requestFocus()
return@LaunchedEffect return@LaunchedEffect
} }
@@ -254,6 +258,8 @@ fun TvPlayerScreen(
onResumePlaybackWithoutShowingControls = resumePlaybackWithoutShowingControls, onResumePlaybackWithoutShowingControls = resumePlaybackWithoutShowingControls,
onSeekRelative = seekByWithoutShowingControls, onSeekRelative = seekByWithoutShowingControls,
onShowControls = showTvControls, onShowControls = showTvControls,
onSkipSegment = skipSegmentAndShowControls,
hasSkippableSegment = uiState.activeSkippableSegmentEndMs != null,
onTogglePlayPause = togglePlayPauseAndShowControls onTogglePlayPause = togglePlayPauseAndShowControls
) )
} }
@@ -385,6 +391,8 @@ internal fun handleTvPlayerRootKeyEvent(
onResumePlaybackWithoutShowingControls: () -> Unit, onResumePlaybackWithoutShowingControls: () -> Unit,
onSeekRelative: (Long) -> Unit, onSeekRelative: (Long) -> Unit,
onShowControls: () -> Unit, onShowControls: () -> Unit,
onSkipSegment: () -> Unit = {},
hasSkippableSegment: Boolean = false,
onTogglePlayPause: () -> Unit onTogglePlayPause: () -> Unit
): Boolean { ): Boolean {
if (event.type != KeyEventType.KeyDown) return false if (event.type != KeyEventType.KeyDown) return false
@@ -428,7 +436,9 @@ internal fun handleTvPlayerRootKeyEvent(
} }
Key.DirectionCenter, Key.Enter -> { Key.DirectionCenter, Key.Enter -> {
if (isPlaying) { if (hasSkippableSegment) {
onSkipSegment()
} else if (isPlaying) {
onPausePlaybackWithoutShowingControls() onPausePlaybackWithoutShowingControls()
} else { } else {
onResumePlaybackWithoutShowingControls() onResumePlaybackWithoutShowingControls()