Reputation: 41
I have an application that begins with an animation on Android. Whenever I run the app from Android Studio onto my phone, the animation appears and runs as expected. When I run the application after building an APK file, the animation doesn't appear at all and does not run. I've tried running coroutine.launch around the delay, etc. and the same issue occured. Also the animation is an .mp4 file format.
@Composable
fun WelcomeView_Bumper(nextRouteCallback: ()-> Unit){
val coroutineScope = rememberCoroutineScope()
LaunchedEffect(key1 = Unit, block = {
delay(6000)
nextRouteCallback()
})
MyTheme {
Surface(color = MaterialTheme.colorScheme.background){
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center){
VideoPlayerView(LocalContext.current, R.raw.bumper_animation_light)
}
}
}
}
And the code from the VideoPlayerView
@Composable
fun VideoPlayerView(context: Context, source: Int, playOnStart: Boolean = true){
val uri = Uri.parse("android.resource://" + context.packageName + "/" + source)
val backgroundColor = if(isSystemInDarkTheme()) colorResource(R.color.cream).value.toInt() else colorResource(R.color.black).value.toInt()
lateinit var videoPlayer : ExoPlayer
DisposableEffect(AndroidView(factory = {
videoPlayer = ExoPlayer.Builder(context).build().also { player ->
player.setMediaItem(MediaItem.Builder().setUri(uri).build())
player.repeatMode = ExoPlayer.REPEAT_MODE_ALL
player.prepare()
if(playOnStart) player.play()
}
PlayerView(context).apply {
player = videoPlayer
// background = resources.getDrawable(R.drawable.background_light)
useController = false
useArtwork = true
defaultArtwork = resources.getDrawable(R.drawable.background_light)
setShutterBackgroundColor(backgroundColor)
}}
)){ onDispose { videoPlayer.release() }}
}
Upvotes: 0
Views: 41