Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play Multi Exoplayer #16

Open
YuSkyBlue opened this issue Jan 2, 2024 · 0 comments
Open

Play Multi Exoplayer #16

YuSkyBlue opened this issue Jan 2, 2024 · 0 comments

Comments

@YuSkyBlue
Copy link

YuSkyBlue commented Jan 2, 2024

I want to know how to play multi-exoplayer like this picture
[explain]

  • one exoplayer is working well but the other one is stop
  • how to play at the same time each of them

hello

fun MultiPlayerScreen(){
  Column(){
    VideoScreen() // 1
    videoScreen() //2
  } 
}
-----------------------------------------------------------------------------------------------------------------------------------
const val MIME_TYPE_DASH = MimeTypes.APPLICATION_MPD
const val MIME_TYPE_HLS = MimeTypes.APPLICATION_M3U8
const val MIME_TYPE_VIDEO_MP4 = MimeTypes.VIDEO_MP4
@Composable
fun VideoScreen(
    onChangeView : () -> Unit,
    durationTime : Long = 8000L,
){
    val currentChangeView by rememberUpdatedState(newValue = onChangeView)
    var repeatMode by remember { mutableStateOf(RepeatMode.ALL) }

    val context = LocalContext.current

    LaunchedEffect(Unit){
        delay(durationTime)
        if(durationTime != 0L) currentChangeView()
    }
     VideoPlayer(
        mediaItems = listOf(
            VideoPlayerMediaItem.NetworkMediaItem(
                url = "https://html5demos.com/assets/dizzy.mp4",
                mediaMetadata = MediaMetadata.Builder().setTitle("Clear MP4: Dizzy").build(),
                mimeType = MIME_TYPE_VIDEO_MP4,
            )

        ),
        handleLifecycle = true,
        autoPlay = true,
        usePlayerController = true,
        enablePip = true,
        handleAudioFocus = true,
        controllerConfig = VideoPlayerControllerConfig.Default.copy(
            showSpeedAndPitchOverlay = false,
            showSubtitleButton = false,
            showCurrentTimeAndTotalTime = true,
            showBufferingProgress = false,
            showForwardIncrementButton = true,
            showBackwardIncrementButton = true,
            showBackTrackButton = true,
            showNextTrackButton = true,
            showRepeatModeButton = true,
            controllerShowTimeMilliSeconds = 5_000,
            controllerAutoShow = true,
            showFullScreenButton = false
        ),
        volume = 0.5f,  // volume 0.0f to 1.0f
        repeatMode = repeatMode,       // or RepeatMode.ALL, RepeatMode.ONE
        onCurrentTimeChanged = { // long type, current player time (millisec)
            Log.e("CurrentTime", it.toString())
        },
        playerInstance = { // ExoPlayer instance (Experimental)
            addAnalyticsListener(object : AnalyticsListener {
                @SuppressLint("UnsafeOptInUsageError")
                override fun onRepeatModeChanged(
                    eventTime: AnalyticsListener.EventTime,
                    rMode: Int,
                ) {
                    repeatMode = rMode.toRepeatMode()
                    Toast.makeText(
                        context,
                        "RepeatMode changed = ${rMode.toRepeatMode()}",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }

                @SuppressLint("UnsafeOptInUsageError")
                override fun onPlayWhenReadyChanged(
                    eventTime: AnalyticsListener.EventTime,
                    playWhenReady: Boolean,
                    reason: Int,
                ) {
                    Toast.makeText(
                        context,
                        "isPlaying = $playWhenReady",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }

                @SuppressLint("UnsafeOptInUsageError")
                override fun onVolumeChanged(
                    eventTime: AnalyticsListener.EventTime,
                    volume: Float,
                ) {
                    Toast.makeText(
                        context,
                        "Player volume changed = $volume",
                        Toast.LENGTH_LONG,
                    )
                        .show()
                }
                }
            )
        },
        modifier = Modifier
            .fillMaxSize()
//           .align(Alignment.Center),
    )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant