Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active August 29, 2022 10:41
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/6b3924ea97b3fe50199a7dda314d567f to your computer and use it in GitHub Desktop.
Save Skyyo/6b3924ea97b3fe50199a7dda314d567f to your computer and use it in GitHub Desktop.
@Composable
fun VideoCard(
videoItem: VideoItem,
isPlaying: Boolean,
exoPlayer: ExoPlayer,
onClick: OnClick
) {
var isPlayerUiVisible by remember { mutableStateOf(false) }
val isPlayButtonVisible = if (isPlayerUiVisible) true else !isPlaying
Box {
if (isPlaying) {
VideoPlayer(exoPlayer) { uiVisible ->
isPlayerUiVisible = when {
isPlayerUiVisible -> uiVisible
else -> true
}
}
} else {
VideoThumbnail(videoItem.thumbnail)
}
if (isPlayButtonVisible) {
Icon(
painter = if (isPlaying) R.drawable.ic_pause else R.drawable.ic_play,
modifier = Modifier.clickable { onClick() })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment