Skip to content

Commit e15f1d9

Browse files
committed
make content crop possible
1 parent 9d68cad commit e15f1d9

File tree

1 file changed

+17
-2
lines changed
  • new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer

1 file changed

+17
-2
lines changed

new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/PlaySurface.kt

+17-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ import androidx.compose.foundation.layout.aspectRatio
2929
import androidx.compose.foundation.layout.fillMaxHeight
3030
import androidx.compose.foundation.layout.fillMaxSize
3131
import androidx.compose.foundation.layout.fillMaxWidth
32+
import androidx.compose.foundation.layout.wrapContentHeight
33+
import androidx.compose.foundation.layout.wrapContentWidth
3234
import androidx.compose.material3.Surface
3335
import androidx.compose.runtime.Composable
3436
import androidx.compose.runtime.DisposableEffect
3537
import androidx.compose.runtime.getValue
3638
import androidx.compose.runtime.mutableStateOf
3739
import androidx.compose.runtime.remember
3840
import androidx.compose.runtime.setValue
41+
import androidx.compose.ui.Alignment
3942
import androidx.compose.ui.Modifier
4043
import androidx.compose.ui.graphics.Color
4144
import androidx.compose.ui.platform.LocalContext
@@ -83,9 +86,21 @@ internal fun PlaySurface(
8386
ActualView(modifier.fillMaxSize(), player)
8487
} else { /* if(fitMode == ContentScale.CROP) */
8588
if (uiRatio <= contentRatio) {
86-
ActualView(modifier.fillMaxHeight(), player)
89+
Box(
90+
modifier = Modifier
91+
.fillMaxSize()
92+
.wrapContentWidth(unbounded = true, align = Alignment.CenterHorizontally)
93+
) {
94+
ActualView(modifier.fillMaxHeight(), player)
95+
}
8796
} else {
88-
ActualView(modifier.fillMaxWidth(), player)
97+
Box(
98+
modifier = Modifier
99+
.fillMaxSize()
100+
.wrapContentHeight(unbounded = true, align = Alignment.CenterVertically)
101+
) {
102+
ActualView(modifier.fillMaxWidth(), player)
103+
}
89104
}
90105
}
91106
}

0 commit comments

Comments
 (0)