Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Created Oct 5, 2021
Embed
What would you like to do?
@Composable
fun VideoCard(
videoItem: VideoItem,
isPlaying: Boolean,
exoPlayer: SimpleExoPlayer,
onClick: OnClick
) {
val isPlayerUiVisible = remember { mutableStateOf(false) }
val isPlayButtonVisible = if (isPlayerUiVisible.value) true else !isPlaying
Box {
if (isPlaying) {
VideoPlayer(exoPlayer) { uiVisible ->
if (isPlayerUiVisible.value) {
isPlayerUiVisible.value = uiVisible
} else {
isPlayerUiVisible.value = 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