fix player for android tv
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ private val controller = koin.get<PlayerController>()
|
||||
fun TestPlayer() {
|
||||
VideoPlayer(controller, modifier = Modifier.fillMaxSize())
|
||||
LaunchedEffect(controller) {
|
||||
controller.load("https://samplelib.com/mp4/sample-5s.mp4")
|
||||
controller.load("https://samplelib.com/mp4/sample-30s-720p.mp4")
|
||||
controller.play()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-7
@@ -1,14 +1,11 @@
|
||||
package ru.shadowsparky.ui.components
|
||||
|
||||
import android.app.UiModeManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
@Composable
|
||||
actual fun isTv(): Boolean {
|
||||
val context = LocalContext.current
|
||||
val uiModeManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
||||
return uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION
|
||||
// val context = LocalContext.current
|
||||
// val uiModeManager = context.getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
||||
// return uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION
|
||||
return true
|
||||
}
|
||||
|
||||
+7
-4
@@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.CircularWavyProgressIndicator
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
@@ -69,7 +68,7 @@ import ru.shadowsparky.videoplayer.PlayerState
|
||||
private const val DEF_SEEK_TIME = 10L
|
||||
|
||||
@Composable
|
||||
fun DefaultControls(
|
||||
fun DefaultControls(
|
||||
state: PlayerState,
|
||||
controlsState: ControlsState,
|
||||
controller: PlayerController,
|
||||
@@ -441,7 +440,11 @@ private fun Modifier.focusableWithBorder(
|
||||
.onFocusChanged { isFocused = it.isFocused }
|
||||
.border(
|
||||
width = 2.dp,
|
||||
color = if (isFocused) MaterialTheme.colorScheme.primary else Color.Transparent,
|
||||
shape = CircleShape
|
||||
color = if (isFocused) {
|
||||
MaterialTheme.colorScheme.primary.copy(alpha = 0.5f)
|
||||
} else {
|
||||
Color.Transparent
|
||||
},
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
)
|
||||
}
|
||||
|
||||
+4
-2
@@ -56,7 +56,7 @@ fun VideoPlayer(
|
||||
val controlsState by remember {
|
||||
mutableStateOf(ControlsState(mutableStateOf(false)))
|
||||
}
|
||||
var areControlsVisible by remember { mutableStateOf(false) }
|
||||
var areControlsVisible by remember { mutableStateOf(true) }
|
||||
var lastErrorMessage by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
LaunchedEffect(controller) {
|
||||
@@ -89,7 +89,9 @@ fun VideoPlayer(
|
||||
val rootModifier = if (isTv) {
|
||||
modifier
|
||||
} else {
|
||||
modifier.clickable { areControlsVisible = !areControlsVisible }
|
||||
modifier.clickable {
|
||||
areControlsVisible = !areControlsVisible
|
||||
}
|
||||
}
|
||||
|
||||
Box(modifier = rootModifier.background(Color.Black)) {
|
||||
|
||||
Reference in New Issue
Block a user