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