Last active
August 29, 2022 10:41
-
-
Save Skyyo/6b3924ea97b3fe50199a7dda314d567f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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