GithubHelp home page GithubHelp logo

imherrera / compose-video-player Goto Github PK

View Code? Open in Web Editor NEW
41.0 1.0 7.0 113 KB

Video player for Jetpack Compose powered by ExoPlayer.

Kotlin 100.00%
android kotlin video-player android-compose exoplayer2 exoplayer android-library android-video-player

compose-video-player's People

Contributors

imherrera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

compose-video-player's Issues

java.lang.IllegalArgumentException: current must not be NaN

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)

Low CPU Device Surface Wrong Orientation

Please complete the following information:

Describe the Bug:

  • when make multiple videoplayer other view is wrong orientation

Solution

  • delay with LaunchedEffect when is ready can drawing surfaceView

Recommend

  • why don't you optional function like boolean value ( isLowCPU) like that

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()
            }
        }

    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.