fix controls focus bug on android tv
This commit is contained in:
+7
-9
@@ -63,6 +63,7 @@ import ru.shadowsparky.videoplayer.AudioTrackInfo
|
||||
import ru.shadowsparky.videoplayer.ControlsState
|
||||
import ru.shadowsparky.videoplayer.PlayerController
|
||||
import ru.shadowsparky.videoplayer.PlayerState
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
private const val DEF_SEEK_TIME = 10L
|
||||
|
||||
@@ -205,7 +206,7 @@ private fun AudioTracksButton(
|
||||
}
|
||||
LaunchedEffect(expanded) {
|
||||
if (expanded) {
|
||||
delay(500)
|
||||
delay(500.milliseconds)
|
||||
tracks.firstOrNull()?.second?.requestFocus()
|
||||
}
|
||||
}
|
||||
@@ -280,8 +281,7 @@ private fun BoxScope.CenterControls(
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.align(Alignment.Center)
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
.focusGroup()
|
||||
.controlsBackground()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
@@ -290,7 +290,6 @@ private fun BoxScope.CenterControls(
|
||||
state.isBuffering -> {
|
||||
CircularWavyProgressIndicator()
|
||||
}
|
||||
|
||||
state.isEnded -> {
|
||||
IconButton(
|
||||
onClick = {
|
||||
@@ -308,7 +307,6 @@ private fun BoxScope.CenterControls(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -357,14 +355,14 @@ private fun BoxScope.CenterControls(
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
}
|
||||
LaunchedEffect(null) {
|
||||
withFrameNanos {}
|
||||
focusContainer.play.requestFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LaunchedEffect(null) {
|
||||
withFrameNanos {}
|
||||
focusContainer.play.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun PlayerController.seek(minus: Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user