Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active June 19, 2022 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyyo/1f08db0c0ff57d4275c3b7f5c0cbb418 to your computer and use it in GitHub Desktop.
Save Skyyo/1f08db0c0ff57d4275c3b7f5c0cbb418 to your computer and use it in GitHub Desktop.
@Composable
fun VideoPlayer(
exoPlayer: ExoPlayer,
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