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