i'm facing an issue regarding the media3 exo player controlls position in a horizoantal tab

37 Views Asked by At

i'm making a video player in jetpack compsoe using media3 exo player. thae problem i'm facing is that in a horizontal tab mode i give an aspect ration of 16/9f to my player and defined 60% of total screen width for the player so the default controlls should be visible inside the defined 60% width but they are visible in the end of screen or outside the defined area for the video player. i'm mentioning the screenshots for my problem

AndroidView(
            factory = {
                PlayerView(context).apply {
                    useController = true
                    resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL
                    player = exoPlayer
                    setShowBuffering(PlayerView.SHOW_BUFFERING_WHEN_PLAYING)
                    hideController()
                    setKeepContentOnPlayerReset(true)
                    setShowNextButton(false)
                    setShowPreviousButton(false)
                    setFullscreenButtonClickListener {
                        isFullscreen = !isFullscreen
                        setScreenValue()
                        handleFullscreen(isFullscreen, context)
                    }
                    controllerShowTimeoutMs = 2000
                    setControllerVisibilityListener(PlayerView.ControllerVisibilityListener { visibility ->
                        isControlVisible = visibility == View.VISIBLE
                        Log.i("fsdsdsdajsdfsdsdsdsdsdsdsdsdsdsdsdsdsdsd", "TravelxpPlayer: hello sid")
                        val selectedAudioLanguage = exoPlayer.audioFormat?.language
                        if (defLanguage != selectedAudioLanguage) {
                            defLanguage = selectedAudioLanguage
                            if (selectedAudioLanguage != null) {
                                coroutineScope.launch {
                                    userStore.setLanguage(selectedAudioLanguage)
                                }
                            }
                        }
                    })
                    val progressBar = findViewById<ProgressBar>(R.id.exo_buffering)
                    progressBar.indeterminateDrawable.setTint(
                        ContextCompat.getColor(context, R.color.travelxp_red),
                    )
                    layoutParams = FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT
                    )
                    setShowSubtitleButton(true)
                }
            }, modifier = Modifier
                .aspectRatio(aspectRatio)
                .fillMaxHeight()
        )```
1

There are 1 best solutions below

1
waseem akram On
layoutParams = FrameLayout.LayoutParams(
    width = definedWidth, // specify the width that fits within 60% of the screen
    height = ViewGroup.LayoutParams.WRAP_CONTENT
)

Modifier.padding(horizontal = paddingValue) // Adjust padding as needed

use matchparent instead of wrapcontent try this if this can help u

that issue come because exo player using default view