Posted by Andrew Lewis – Software Engineer

This article is cross-published on Medium
This release includes a host of bug fixes, performance improvements and new features. Read on to find out more, and as always please check out the full release notes for a comprehensive overview of changes in this release.
Playback, MediaSession and UI
ExoPlayer now supports HLS interstitials for ad insertion in HLS streams. To play these ads using ExoPlayer’s built-in playlist support, pass an HlsInterstitialsAdsLoader.AdsMediaSourceFactory as the media source factory when creating the player. For more information see the official documentation.
This release also includes experimental support for ‘pre-warming’ decoders. Without pre-warming, transitions from one playlist item to the next may not be seamless in some cases, for example, we may need to switch codecs, or decode some video frames to reach the start position of the new media item. With pre-warming enabled, a secondary video renderer can start decoding the new media item earlier, giving near-seamless transitions. You can try this feature out by enabling it on the DefaultRenderersFactory. We’re actively working on further improvements to the way we interact with decoders, including adding a ‘fast seeking mode’ so stay tuned for updates in this area.
Media3 1.6.0 introduces a new media3-ui-compose module that contains functionality for building Compose UIs for playback. You can find a reference implementation in the Media3 Compose demo and learn more in Getting started with Compose-based UI. At this point we’re providing a first set of foundational state classes that link to the Player, in addition to some basic composable building blocks. You can use these to build your own customized UI widgets. We plan to publish default Material-themed composables in a later release.
Some other improvements in this release include: moving system calls off the application’s main thread to the background (which should reduce Anrs), a new decoder module wrapping libmpegh (for bundling object-based audio decoding in your app), and a fix for the Cast extension for apps targeting API 34+. There are also fixes across MPEG-TS and WebVTT extraction, DRM, downloading/caching, MediaSession and more.
Media extraction and frame retrieval
The new MediaExtractorCompat is a drop-in replacement for the framework MediaExtractor but implemented using Media3’s extractors. If you’re using the Android framework MediaExtractor, consider migrating to get consistent behavior across devices and reduce crashes.
We’ve also added experimental support for retrieving video frames in a new class ExperimentalFrameExtractorwhich can act as a replacement for the MediaMetadataRetriever getFrameAtTime methods. There are a few benefits over the framework implementation: HDR input is supported (by default tonemapping down to SDR, but with the option to produce HLG bitmaps from Android 14 onwards), Media3 effects can be applied (including Presentation to scale the output to a desired size) and it runs faster on some devices due to moving color space conversion to the GPU. Here’s an example of using the new API:
val bitmap =
withContext(Dispatchers.IO) {
val configuration =
ExperimentalFrameExtractor.Configuration
.Builder()
.setExtractHdrFrames(true)
.build()
val frameExtractor =
ExperimentalFrameExtractor(
context,
configuration,
)
frameExtractor.setMediaItem(mediaItem, /*effects*/ listOf())
val frame = frameExtractor.getFrame(timestamps).await()
frameExtractor.release()
frame.bitmap
}
Editing, transcoding and export
Media3 1.6.0 includes performance, stability and functional improvements in Transformer. Highlights include: support for transcoding/transmuxing Dolby Vision streams on devices that support this format and a new MediaProjectionAssetLoader for recording from the screen, which you can try out in the Transformer demo app.
Check out Common media processing operations with Jetpack Media3 Transformer for some code snippets showing how to process media with Transformer, and tips to reduce latency.
This release also includes a new Kotlin-based demo app showcasing Media3’s video effects framework. You can select from a variety of video effects and preview them via ExoPlayer.setVideoEffects.
Animation showing contrast adjustment and a confetti effect in the new demo app
Get started sith Media3 1.6.0
Please get in touch via the Media3 issue Tracker if you run into any bugs, or if you have questions or feature requests. We look forward to hearing from you!
GIPHY App Key not set. Please check settings