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