我有一个播放器(在我的例子中是 ExoPlayer),并且有一个视频 URL。我想同时在多个视图中播放该视频,如下面的屏幕截图所示。以下是一些注意事项:
//Jetpack compose
//player -> exo player builder
AndroidView(
factory = {SurfaceView(applicationContext) }, modifier = Modifier
.padding(1.dp)
.aspectRatio(16f / 9f)
.clip(
RoundedCornerShape(10.dp)
),
update = { surfaceView1 -> // This is the lambda you're asking about
player.setVideoSurface(surfaceView1.holder.surface)
}
)
AndroidView(factory = { SurfaceView(applicationContext) }, modifier = Modifier
.padding(1.dp)
.aspectRatio(16f / 9f)
.clip(
RoundedCornerShape(10.dp)
)) {
player.setVideoSurface(it.holder.surface)
}
AndroidView(factory = { SurfaceView(applicationContext) }, modifier = Modifier
.padding(1.dp)
.aspectRatio(16f / 9f)
.clip(
RoundedCornerShape(10.dp)
)) {
player.setVideoSurface(it.holder.surface)
截图: