foo
This commit is contained in:
parent
5ee7398f64
commit
3903e89781
|
@ -104,27 +104,47 @@ fun VideoPlayerUI(
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.aspectRatio(uiState.uiRatio),
|
.aspectRatio(uiState.uiRatio), color = Color.Black
|
||||||
color = Color.Black
|
|
||||||
) {
|
) {
|
||||||
Box(contentAlignment = Alignment.Center) {
|
Box(contentAlignment = Alignment.Center) {
|
||||||
AndroidView(
|
val viewBoxModifier = Modifier
|
||||||
modifier = Modifier.also { modifier ->
|
|
||||||
when (uiState.contentFitMode) {
|
when (uiState.contentFitMode) {
|
||||||
ContentFitMode.FILL -> modifier.fillMaxSize()
|
ContentFitMode.FILL -> {
|
||||||
ContentFitMode.FIT_INSIDE -> if (uiState.contentRatio < uiState.uiRatio) {
|
println("fit mode fill")
|
||||||
modifier.fillMaxHeight().aspectRatio(uiState.contentRatio)
|
viewBoxModifier.fillMaxSize()
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentFitMode.FIT_INSIDE -> {
|
||||||
|
println("fit mode fit inside:")
|
||||||
|
if (uiState.contentRatio < uiState.uiRatio) {
|
||||||
|
println("fit mode fill max height")
|
||||||
|
viewBoxModifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.aspectRatio(uiState.contentRatio)
|
||||||
} else if (uiState.uiRatio < uiState.contentRatio) {
|
} else if (uiState.uiRatio < uiState.contentRatio) {
|
||||||
modifier.fillMaxWidth().aspectRatio(uiState.contentRatio)
|
println("fit mode fill max width")
|
||||||
|
viewBoxModifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(uiState.contentRatio)
|
||||||
}
|
}
|
||||||
ContentFitMode.ZOOM -> if(uiState.uiRatio < uiState.contentRatio) {
|
}
|
||||||
modifier.fillMaxHeight().aspectRatio(uiState.contentRatio)
|
|
||||||
|
ContentFitMode.ZOOM -> {
|
||||||
|
println("fit mode zoom:")
|
||||||
|
if (uiState.uiRatio < uiState.contentRatio) {
|
||||||
|
viewBoxModifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.aspectRatio(uiState.contentRatio)
|
||||||
} else if (uiState.contentRatio < uiState.uiRatio) {
|
} else if (uiState.contentRatio < uiState.uiRatio) {
|
||||||
modifier.fillMaxWidth().aspectRatio(uiState.contentRatio)
|
viewBoxModifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.aspectRatio(uiState.contentRatio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
factory = { context ->
|
|
||||||
|
Box(modifier = viewBoxModifier) {
|
||||||
|
AndroidView(factory = { context ->
|
||||||
SurfaceView(context).also { view ->
|
SurfaceView(context).also { view ->
|
||||||
viewModel.player?.setVideoSurfaceView(view)
|
viewModel.player?.setVideoSurfaceView(view)
|
||||||
}
|
}
|
||||||
|
@ -137,7 +157,11 @@ fun VideoPlayerUI(
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Surface(color = Color.Green, modifier = Modifier.fillMaxSize()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
VideoPlayerControllerUI(
|
VideoPlayerControllerUI(
|
||||||
isPlaying = uiState.playing,
|
isPlaying = uiState.playing,
|
||||||
fullscreen = uiState.fullscreen,
|
fullscreen = uiState.fullscreen,
|
||||||
|
@ -151,7 +175,7 @@ fun VideoPlayerUI(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(device = "spec:width=1080px,height=700px,dpi=440,orientation=landscape")
|
@Preview(device = "spec:width=1080px,height=700px,dpi=440,orientation=landscape")
|
||||||
@Composable
|
@Composable
|
||||||
|
|
Loading…
Reference in New Issue