Modernizing ExoPlayer with Media3’s Compose UI
Article Summary
For years, video playback was the one piece of Android UI that refused to go fully declarative. That changed when Google shipped Media3's Compose UI module.
Ioannis Anifantakis walks through migrating ExoPlayer from the old AndroidView + PlayerView pattern to Media3's native Compose components. This is a practical, code-heavy guide showing what changed in Media3 1.6.0 and 1.8.0, and why it matters for Compose-first apps.
Key Takeaways
- PlayerSurface replaces AndroidView wrapping, making video just another Composable
- State holders like rememberPlayPauseButtonState eliminate manual Player.Listener boilerplate
- Media3 1.8.0 includes workarounds for Android 14 SurfaceView bugs
- Custom overlays and scrubbers become trivial with standard Box layouts
- Lifecycle management aligns with Compose patterns using DisposableEffect
Media3's Compose UI module eliminates the View-Compose interop tax for video playback, making ExoPlayer a first-class citizen in declarative Android apps.
About This Article
Building ExoPlayer apps meant writing a lot of boilerplate code. Developers had to manually implement Player.Listener to convert player events into Compose state, which made it easy to miss something when the UI needed to show buffering or playback status.
Media3 includes state holders like rememberPlayPauseButtonState and rememberPresentationState that automatically listen to Player events and give you clean UI state with onClick handlers ready to use. You don't have to wire up listeners yourself.
Developers can build complete player UIs in Compose without needing AndroidView interop. This cuts down on code and makes video playback work the same way as the rest of your Compose UI.