Alex
04/12/2021, 1:38 PMAlex
04/12/2021, 1:39 PM@Composable
fun VideoRenderView(
modifier: Modifier = Modifier,
videoRenderViewModel: VideoRenderViewModel,
update: TextureView.(SimpleExoPlayer) -> Unit,
) {
AndroidView(
factory = { context ->
val textureView = TextureView(context)
val player = videoRenderViewModel.player
player.setVideoTextureView(textureView)
textureView.tag = player
textureView
},
modifier = modifier,
update = {
update(it, it.tag as SimpleExoPlayer)
}
)
}
Within the factory I set the textureView as output to the player. Since the player has a different lifecycle I probably have to unset the textureView (e.g. player.setVideoTextureView(null)
) somewhere.
Is there a place for those things in compose?Halil Ozercan
04/12/2021, 2:24 PMDisposableEffect
Alex
04/13/2021, 7:40 AM