fix fullscreen finally

This commit is contained in:
Christian Schabesberger 2024-07-23 17:50:52 +02:00
parent b3b7bb18ea
commit d4a7c68e5f
3 changed files with 59 additions and 58 deletions

View File

@ -4,7 +4,7 @@
<selectionStates>
<SelectionState runConfigName="TestApp">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-07-23T15:11:36.844182977Z">
<DropdownSelection timestamp="2024-07-23T15:40:12.466915691Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=981f7af2" />

View File

@ -106,15 +106,18 @@ fun VideoPlayerControllerUI(
) {
val insets = WindowInsets.systemBars
Box(
modifier = Modifier.then(
if (fullscreen)
Modifier.windowInsetsPadding(insets)
else
Modifier
if (!uiVissible) {
TouchUi(
modifier = Modifier.fillMaxSize(),
hideUi = hideUi,
showUi = showUi,
uiVissible = uiVissible,
fullscreen = fullscreen
)
) {
if (!uiVissible) {
} else {
Surface(
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
) {
TouchUi(
modifier = Modifier.fillMaxSize(),
hideUi = hideUi,
@ -122,53 +125,44 @@ fun VideoPlayerControllerUI(
uiVissible = uiVissible,
fullscreen = fullscreen
)
} else {
Surface(
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
) {
TouchUi(
modifier = Modifier.fillMaxSize(),
hideUi = hideUi,
showUi = showUi,
uiVissible = uiVissible,
fullscreen = fullscreen
)
Box(
modifier = if (fullscreen) {
Modifier
.background(Color.Transparent)
} else {
Modifier
.background(Color.Transparent)
}
) {
TopUI(
modifier = Modifier
.align(Alignment.TopStart)
.fillMaxWidth()
.defaultMinSize(minHeight = 45.dp)
.padding(top = 4.dp, start = 16.dp, end = 16.dp)
)
CenterUI(
modifier = Modifier.align(Alignment.Center),
isPlaying,
play = play,
pause = pause,
prevStream = prevStream,
nextStream = nextStream
)
BottomUI(
modifier = Modifier
.align(Alignment.BottomStart)
.padding(start = 16.dp, end = 16.dp)
.defaultMinSize(minHeight = 40.dp)
.fillMaxWidth(),
isFullscreen = fullscreen,
switchToFullscreen,
switchToEmbeddedView
)
Box(
modifier = if (fullscreen) {
Modifier
.background(Color.Transparent)
.windowInsetsPadding(insets)
} else {
Modifier
.background(Color.Transparent)
}
) {
TopUI(
modifier = Modifier
.align(Alignment.TopStart)
.fillMaxWidth()
.defaultMinSize(minHeight = 45.dp)
.padding(top = 4.dp, start = 16.dp, end = 16.dp)
)
CenterUI(
modifier = Modifier.align(Alignment.Center),
isPlaying,
play = play,
pause = pause,
prevStream = prevStream,
nextStream = nextStream
)
BottomUI(
modifier = Modifier
.align(Alignment.BottomStart)
.padding(start = 16.dp, end = 16.dp)
.defaultMinSize(minHeight = 40.dp)
.fillMaxWidth(),
isFullscreen = fullscreen,
switchToFullscreen,
switchToEmbeddedView
)
}
}
}
if (fullscreen) {

View File

@ -98,9 +98,12 @@ fun VideoPlayerUI(
// Set UI
Surface(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(uiState.embeddedUiRatio), color = Color.Black
modifier = Modifier.then(
if (uiState.fullscreen) Modifier.fillMaxSize()
else Modifier
.fillMaxWidth()
.aspectRatio(uiState.embeddedUiRatio)
), color = Color.Black
) {
Box(contentAlignment = Alignment.Center) {
PlaySurface(
@ -162,7 +165,11 @@ fun PlaySurface(
)
) {
*/
Box(modifier = Modifier.fillMaxHeight().aspectRatio(contentRatio)) {
Box(
modifier = Modifier
.fillMaxHeight()
.aspectRatio(contentRatio)
) {
AndroidView(factory = { context ->
SurfaceView(context).also { view ->
player?.setVideoSurfaceView(view)