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> <selectionStates>
<SelectionState runConfigName="TestApp"> <SelectionState runConfigName="TestApp">
<option name="selectionMode" value="DROPDOWN" /> <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"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=981f7af2" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=981f7af2" />

View File

@ -106,15 +106,18 @@ fun VideoPlayerControllerUI(
) { ) {
val insets = WindowInsets.systemBars val insets = WindowInsets.systemBars
Box( if (!uiVissible) {
modifier = Modifier.then( TouchUi(
if (fullscreen) modifier = Modifier.fillMaxSize(),
Modifier.windowInsetsPadding(insets) hideUi = hideUi,
else showUi = showUi,
Modifier uiVissible = uiVissible,
fullscreen = fullscreen
) )
) { } else {
if (!uiVissible) { Surface(
modifier = Modifier.fillMaxSize(), color = Color(0x75000000)
) {
TouchUi( TouchUi(
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
hideUi = hideUi, hideUi = hideUi,
@ -122,53 +125,44 @@ fun VideoPlayerControllerUI(
uiVissible = uiVissible, uiVissible = uiVissible,
fullscreen = fullscreen fullscreen = fullscreen
) )
} else {
Surface( Box(
modifier = Modifier.fillMaxSize(), color = Color(0x75000000) modifier = if (fullscreen) {
) { Modifier
TouchUi( .background(Color.Transparent)
modifier = Modifier.fillMaxSize(), .windowInsetsPadding(insets)
hideUi = hideUi, } else {
showUi = showUi, Modifier
uiVissible = uiVissible, .background(Color.Transparent)
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
)
} }
) {
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) { if (fullscreen) {

View File

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