0

I'm using ExoPlayer and PlayerView to render videos in Compose as follows:

val exoPlayer = remember(videoUrl) {
        ExoPlayer.Builder(this).build().apply {
            setMediaItem(MediaItem.fromUri(videoUrl))
        }
    }


AndroidView(
     factory = {
        PlayerView(it).apply {
           player = exoPlayer
        }
     }
)

The original video is on the left, the PlayerView version is on the right The original video is on the left, the PlayerView version is on the right

It renders perfectly, but as you see, there is a slight color difference compared to the original video. It seems that PlayerView adds a dim to the original video or changes some configuration related to the UI. I tried multiple things to get the same color but failed.

Any hint to get the same video color in PlayerView?

1 Answer 1

0

This color difference is usually caused by the default background or overlay of PlayerView. By default, PlayerView applies a semi-transparent overlay and a black background, which can affect perceived video colors.

Set the background of PlayerView to transparent and disable the default overlay.

AndroidView(
    factory = { context ->
        PlayerView(context).apply {
            player = exoPlayer
            setShutterBackgroundColor(android.graphics.Color.TRANSPARENT) // Remove black shutter
            useController = false // Optional: hide controls if not needed
            // Remove default overlay
            overlayFrameLayout?.background = null
            setBackgroundColor(android.graphics.Color.TRANSPARENT)
        }
    }
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.