imherrera / compose-video-player Goto Github PK
View Code? Open in Web Editor NEWVideo player for Jetpack Compose powered by ExoPlayer.
Video player for Jetpack Compose powered by ExoPlayer.
FATAL EXCEPTION: main
java.lang.IllegalArgumentException: current must not be NaN
at androidx.compose.ui.semantics.ProgressBarRangeInfo.(SemanticsProperties.kt:489)
at androidx.compose.foundation.ProgressSemanticsKt$progressSemantics$1.invoke(ProgressSemantics.kt:52)
at androidx.compose.foundation.ProgressSemanticsKt$progressSemantics$1.invoke(ProgressSemantics.kt:50)
at androidx.compose.ui.semantics.SemanticsModifierCore.(SemanticsModifier.kt:57)
at androidx.compose.ui.semantics.SemanticsModifierKt.semantics(SemanticsModifier.kt:110)
at androidx.compose.foundation.ProgressSemanticsKt.progressSemantics(ProgressSemantics.kt:50)
at androidx.compose.foundation.ProgressSemanticsKt.progressSemantics$default(ProgressSemantics.kt:41)
at androidx.compose.material.ProgressIndicatorKt.LinearProgressIndicator-eaDK9VM(ProgressIndicator.kt:80)
at com.imherrera.videoplayer.VideoPlayerControlKt.TimelineControl-8V94_ZQ(VideoPlayerControl.kt:191)
at com.imherrera.videoplayer.VideoPlayerControlKt.access$TimelineControl-8V94_ZQ(VideoPlayerControl.kt:1)
at com.imherrera.videoplayer.VideoPlayerControlKt$VideoPlayerControl$1.invoke(VideoPlayerControl.kt:53)
at com.imherrera.videoplayer.VideoPlayerControlKt$VideoPlayerControl$1.invoke(VideoPlayerControl.kt:34)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at com.imherrera.videoplayer.VideoPlayerControlKt.VideoPlayerControl-EMNEwkI(VideoPlayerControl.kt:34)
Please complete the following information:
Describe the Bug:
Solution
Recommend
Class[VideoPlayer.kt]
@Composable
private fun VideoPlayer(
modifier: Modifier,
playerState: VideoPlayerState,
controller: @Composable () -> Unit
) {
val configuration = LocalConfiguration.current
when (configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> {
Log.d("VideoScreen", "LandScape3")
}
else -> {
Log.d("VideoScreen", "Portrait3")
}
}
var isSurfaceViewInitialized by remember { mutableStateOf(false) }
// Delay coroutine
LaunchedEffect(isSurfaceViewInitialized) {
delay(1000) // Adjust the delay time as needed
isSurfaceViewInitialized = true // <- when is delay done change the flag
}
DisposableEffect(configuration.orientation) {
onDispose {
// Clean up any resources on orientation change
// For example, you might want to release the player or reset the surface view
playerState.player.setVideoSurfaceView(null)
}
}
Box(modifier = modifier.defaultPlayerTapGestures(playerState)) {
if(isSurfaceViewInitialized){ // <- start draw surfaceView
AndroidView(
modifier = Modifier.adaptiveLayout(
aspectRatio = playerState.videoSize.value.aspectRatio(),
resizeMode = playerState.videoResizeMode.value
),
factory = { context ->
SurfaceView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
}.also {
playerState.player.setVideoSurfaceView(it)
}
}
)
AnimatedVisibility(
visible = playerState.isControlUiVisible.value,
enter = fadeIn(),
exit = fadeOut()
) {
controller()
}
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.