fix controls focus
This commit is contained in:
+15
-9
@@ -89,8 +89,10 @@ fun DefaultControls(
|
||||
.safeDrawingPadding()
|
||||
) {
|
||||
SideDoubleTapSeekZones(controller)
|
||||
Box(modifier = Modifier.align(Alignment.TopStart).padding(8.dp)) {
|
||||
BackButton(Color.White) { onBack() }
|
||||
if (!isUiLocked.value) {
|
||||
Box(modifier = Modifier.align(Alignment.TopStart).padding(8.dp)) {
|
||||
BackButton(Color.White) { onBack() }
|
||||
}
|
||||
}
|
||||
Row(modifier = Modifier.align(Alignment.TopEnd).focusGroup().padding(8.dp)) {
|
||||
if (audioTracksState.isNotEmpty() && !isUiLocked.value) {
|
||||
@@ -252,11 +254,9 @@ private fun BoxScope.SideDoubleTapSeekZones(controller: PlayerController, enable
|
||||
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
private fun BoxScope.CenterControls(
|
||||
state: PlayerState,
|
||||
controller: PlayerController
|
||||
) {
|
||||
private fun BoxScope.CenterControls(state: PlayerState, controller: PlayerController) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
var canRequestFocus by remember { mutableStateOf(false) }
|
||||
Box(
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
@@ -283,13 +283,13 @@ private fun BoxScope.CenterControls(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
IconButton(
|
||||
modifier = Modifier.focusRequester(focusRequester),
|
||||
onClick = {
|
||||
scope.launch {
|
||||
if (state.isPlaying) controller.pause() else controller.play()
|
||||
@@ -309,11 +309,17 @@ private fun BoxScope.CenterControls(
|
||||
)
|
||||
}
|
||||
}
|
||||
canRequestFocus = true
|
||||
LaunchedEffect(canRequestFocus) {
|
||||
if (canRequestFocus) {
|
||||
withFrameNanos {}
|
||||
focusRequester.requestFocus()
|
||||
canRequestFocus = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LaunchedEffect(state.videoUrl) { canRequestFocus = false }
|
||||
LaunchedEffect(state.videoUrl) { canRequestFocus = true }
|
||||
}
|
||||
|
||||
private suspend fun PlayerController.seek(minus: Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user