Skip to content

Instantly share code, notes, and snippets.

Avatar

Ruben Quadros rubenquadros

  • Bangalore
View GitHub Profile
@rubenquadros
rubenquadros / GameVideoTest.kt
Created Sep 4, 2021
Testing game videos screen
View GameVideoTest.kt
class GameVideoTest() {
@get:Rule val composeTestRule = createComposeRule()
@Test
fun vide_player_and_playlist_show_be_shown() {
composeTestRule.setContent {
ShowGameVideos(
gameVideos =
FakeGamesData.getFakeGameVideos()
View VideoItemFinal.kt
@Composable
fun VideoItem(
index: Int,
video: VideoResultEntity,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
val currentlyPlaying = remember {
mutableStateOf(false)
}
View VideoPlayListFinal.kt
@Composable
fun VideoPlayList(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
LazyColumn(modifier = modifier) {
itemsIndexed(
items = gameVideos,
@rubenquadros
rubenquadros / VideoPlayer.kt
Created Sep 4, 2021
Video player to play videos
View VideoPlayer.kt
@ExperimentalAnimationApi
@Composable
fun VideoPlayer(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>,
currentPlaying: State<Int>,
onVideoChange: (Int) -> Unit
) {
val videoTitle = remember {
@rubenquadros
rubenquadros / ShowGameVideos.kt
Created Sep 4, 2021
Showing game video and playlist
View ShowGameVideos.kt
@ExperimentalAnimationApi
@Composable
fun ShowGameVideos(gameVideos: GameVideosEntity) {
val playingIndex = remember { mutableStateOf(0) }
// keep track of current playing video
fun onVideoChange(index: Int) {
playingIndex.value = index
}
@rubenquadros
rubenquadros / VideoItem.kt
Last active Sep 4, 2021
Video item in playlist
View VideoItem.kt
@Composable
fun VideoItem(index: Int, video: VideoResultEntity) {
val currentlyPlaying = remember { mutableStateOf(true) }
ConstraintLayout(
modifier =
Modifier.testTag("VideoParent")
.padding(8.dp)
.wrapContentSize()
) {
@rubenquadros
rubenquadros / VideoPlayList.kt
Created Sep 4, 2021
Show all videos in a playlist
View VideoPlayList.kt
@Composable
fun VideoPlayList(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>
) {
LazyColumn(modifier = modifier) {
itemsIndexed(
items = gameVideos,
key = { _, item -> item.id }
) { index, item ->
@rubenquadros
rubenquadros / VideoPlayerTitle.kt
Created Sep 4, 2021
Video title of current playing video
View VideoPlayerTitle.kt
@ExperimentalAnimationApi
@Composable
fun VideoPlayer(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>
) {
val context = LocalContext.current
val mediaItems = arrayListOf<MediaItem>()
val videoTitle = remember {
@rubenquadros
rubenquadros / VideoPlayerPlaylist.kt
Created Sep 4, 2021
Playing videos in the video player
View VideoPlayerPlaylist.kt
@Composable
fun VideoPlayer(
modifier: Modifier = Modifier,
gameVideos: List<VideoResultEntity>
) {
val context = LocalContext.current
val mediaItems = arrayListOf<MediaItem>()
// create MediaItem
gameVideos.forEach {
View VideoPlayerInitial.kt
@Composable
fun VideoPlayer(modifier: Modifier = Modifier) {
val context = LocalContext.current
// create our player
val exoPlayer = remember {
SimpleExoPlayer.Builder(context).build().apply {
this.prepare()
}
}