Skip to content

Commit

Permalink
More refinement of video playback
Browse files Browse the repository at this point in the history
  • Loading branch information
creativedrewy committed Aug 27, 2021
1 parent 9b530b2 commit 5d8e23e
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
Expand All @@ -31,6 +32,7 @@ import com.creativedrewy.nativ.viewmodel.Model3d
import com.creativedrewy.nativ.viewmodel.NftViewProps
import com.google.accompanist.glide.rememberGlidePainter
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.ui.PlayerView
import com.google.android.filament.Skybox
Expand Down Expand Up @@ -97,7 +99,11 @@ fun VideoViewer(
) {
val context = LocalContext.current
val player = SimpleExoPlayer.Builder(context).build()
player.repeatMode = Player.REPEAT_MODE_ALL

val playerView = PlayerView(context)
playerView.controllerAutoShow = false
playerView.hideController()

player.setMediaItem(MediaItem.fromUri(nftProps.videoUrl))
playerView.player = player
Expand All @@ -112,6 +118,8 @@ fun VideoViewer(
}

AndroidView(
modifier = Modifier
.align(Alignment.Center),
factory = { playerView }
)
}
Expand Down

0 comments on commit 5d8e23e

Please sign in to comment.