Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Composable
fun VideoPlayer(
exoPlayer: SimpleExoPlayer,
onControllerVisibilityChanged: (uiVisible: Boolean) -> Unit
) {
val context = LocalContext.current
val playerView = remember {
val layout = LayoutInflater.from(context).inflate(R.layout.video_player, null, false)
val playerView = layout.findViewById(R.id.playerView) as PlayerView
playerView.apply {
setControllerVisibilityListener { onControllerVisibilityChanged(it == View.VISIBLE) }
player = exoPlayer
}
}
AndroidView({ playerView })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment