From 127ae66ac79e750175481910e776a056c3291edf Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 1 Nov 2024 23:57:18 +0100 Subject: [PATCH] make aspect ratio not be out of place in embedded view --- .../newplayer/ui/videoplayer/PlaySurface.kt | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/PlaySurface.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/PlaySurface.kt index 0ff9429..ec9e9b7 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/PlaySurface.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/PlaySurface.kt @@ -75,33 +75,39 @@ internal fun PlaySurface( // actual calculation of the aspect ratio - if (uiState.uiMode.fullscreen && fitMode == ContentScale.STRETCHED) - ActualView(modifier.fillMaxSize(), player) - else { - val modifier = modifier.aspectRatio(contentRatio) - if (fitMode == ContentScale.FIT_INSIDE) { + if(!uiState.uiMode.fullscreen) { + ActualView(modifier.fillMaxHeight().aspectRatio(contentRatio), player) + } else { + if (fitMode == ContentScale.STRETCHED) { ActualView(modifier.fillMaxSize(), player) - } else { /* if(fitMode == ContentScale.CROP) */ - if (uiRatio <= contentRatio) { - Box( - modifier = Modifier - .fillMaxSize() - .wrapContentWidth(unbounded = true, align = Alignment.CenterHorizontally) - ) { - ActualView(modifier.fillMaxHeight(), player) - } - } else { - Box( - modifier = Modifier - .fillMaxSize() - .wrapContentHeight(unbounded = true, align = Alignment.CenterVertically) - ) { - ActualView(modifier.fillMaxWidth(), player) + } else { + val modifier = modifier.aspectRatio(contentRatio) + if (fitMode == ContentScale.FIT_INSIDE) { + ActualView(modifier.fillMaxSize(), player) + } else { /* if(fitMode == ContentScale.CROP) */ + if (uiRatio <= contentRatio) { + Box( + modifier = Modifier + .fillMaxSize() + .wrapContentWidth( + unbounded = true, + align = Alignment.CenterHorizontally + ) + ) { + ActualView(modifier.fillMaxHeight(), player) + } + } else { + Box( + modifier = Modifier + .fillMaxSize() + .wrapContentHeight(unbounded = true, align = Alignment.CenterVertically) + ) { + ActualView(modifier.fillMaxWidth(), player) + } } } } } - } @Composable