0

I am working with Media3 ExoPlayer in Jetpack Compose and I am trying to customize the player's control view. Specifically, I want to disable or remove the progress bar (the one that shows the playing status of the video) and the 15 seconds back and forth buttons in the live mode.

Here is the current implementation of my VideoView function:

@Composable
fun VideoView(video: string?, viewModel: ChannelsViewModel = viewModel()) {
    val context = LocalContext.current
    if(videoUri == null){
        throw Error("error")
    }
    val exoPlayer = ExoPlayer.Builder(LocalContext.current)
        .build()
        .also { exoPlayer ->
            val mediaItem = MediaItem.Builder()
                .setUri(video)
                .build()
            exoPlayer.setMediaItem(mediaItem)
            exoPlayer.prepare()
            exoPlayer.playWhenReady = true
        }

    DisposableEffect(
        AndroidView(factory = {
        PlayerView(context).apply {
            player = exoPlayer
            layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
        }
    })
    )
    {
        onDispose { exoPlayer.release() }
    }
}

Thanks in advance for any help you can provide.

IdanB
  • 167
  • 1
  • 3
  • 13

1 Answers1

1

You can add this style to your res/values/styles folder. This will make the progressbar vissible, but not clickable/draggable. <style name="ExoStyledControls.TimeBar" tools:override="true"> <item name="touch_target_height" tools:override="true">0dp</item> </style>

Then add these 2 functions to your playerView as shown here to remove the "jump forward/backward" buttons PlayerView(context).apply { setShowFastForwardButton(false) setShowRewindButton(false) }

Mats
  • 166
  • 1
  • 6
  • The setShowFastForwardButton() and setShowRewindButton() functions are currently marked as @UnstableApi in the version of ExoPlayer I am using. This suggests that they might undergo significant changes in the future or even be removed. I am looking for a solution that would be appropriate for a production environment where stability is crucial. Could you please suggest an alternative approach that does not rely on unstable APIs? – IdanB Jul 07 '23 at 14:04
  • in that case you can continue to override the Style for the different parts of the ui you want gone or altered, like for example ` ` – Mats Jul 07 '23 at 15:54