ExoPlayer 2.12 - What’s new

Olly Woodman
AndroidX Media3
Published in
5 min readSep 13, 2020

ExoPlayer 2.12 contains many new features, improvements and bug fixes. This post highlights some of the most significant changes.

Top-level playlist API

The biggest change in the 2.12 release is that playlist support has been added directly to the player’s top-level API, along with a new MediaItem class for defining content to be played. Rather than using ConcatenatingMediaSource for playlist management, it’s now possible to simply define and add multiple media items directly to the player:

The playlist can be modified before and during playback, and the MediaItem class supports features such as clipping and attaching side-loaded subtitle files. For advanced use cases, it’s still possible to pass MediaSource instances directly to the player.

Learn more by reading the playlists and media item pages of the developer guide. We’ve also written a separate blog post about the playlist changes in 2.12, which you can read here.

UI components

ExoPlayer 2.12 adds new StyledPlayerView and StyledPlayerControlView components. They have similar APIs to the existing PlayerView and PlayerControlView components, but provide a more polished user experience including:

  • Animation effects when hiding and showing the controls.
  • Built in support for subtitle and audio track selection.
  • Built in support for playback speed selection.
  • The fast-forward and rewind durations are rendered on the corresponding buttons.
  • Automatic adaptation to different view sizes. If the view size becomes small, buttons are automatically moved into an overflow menu. If the view becomes even smaller, a minimal layout is applied.

Media2 extension

Integrating your media player with an Android MediaSession allows playbacks in your application to be controlled via Bluetooth media control keys, Google Assistant, Android Auto, and other applications running on the user’s device.

Previous releases of ExoPlayer included a MediaSession extension that made it easy to integrate ExoPlayer with the (now legacy) MediaSessionCompat implementation of MediaSession.

ExoPlayer 2.12 introduces a new media2 extension that makes it easy to integrate with the latest AndroidX media2 MediaSession API. Migrating to this MediaSession implementation brings a number of benefits such as finer grained permissions.

We’ve written a separate blog post describing the media2 extension in more detail, which you can read here.

Japanese subtitles

This release adds support for two features used in Japanese subtitles: rubies and vertical text. To try this out in your application:

  • Use a WebVTT or TTML source file that uses Japanese subtitle features.
  • Enable rendering using SubtitleView.setViewType(VIEW_TYPE_WEB). If using StyledPlayerView or PlayerView, you can access the SubtitleView to configure its view type with PlayerView.getSubtitleView().

Take a look at our in-depth blog post on this topic for more details!

Audio offload

This release adds experimental support for audio offload playback on Android 10+. Audio offload can be used to significant reduce battery usage during long audio playbacks with the screen off. It does so by using an audio co-processor instead of the main CPU.

Similarly to tunneling mode for video, audio offload has some device specific restrictions. Devices may support offload playback of MP3 and AAC on Android 10+, and Opus on Android 11+. Speed adjustment and other audio processing effects cannot be used in conjunction with audio offload, but it may be possible to use some framework AudioEffects with offload enabled.

Audio offload can be enabled by calling setEnableAudioOffload on a DefaultRenderersFactory that’s injected when building the player. To get the full power saving, offload scheduling must also be enabled when appropriate by calling ExoPlayer.experimentalSetOffloadSchedulingEnabled on the player. Refer to the method Javadoc for more details.

Faster downloads

In previous releases, ExoPlayer’s downloader functionality would serialize the download of segments belonging to adaptive content such as DASH and HLS streams.

In ExoPlayer 2.12, downloaders now intelligently merge segment downloads where segments have the same URL and adjacent byte ranges. Segment downloads can also proceed in parallel, on an Executor provided by the application. See the creating a download manager section of the developer guide for an example of how to do this. Applications that already have an executor for background downloads may wish to reuse their existing executor. Downloaders will drip-feed segment download tasks to the executor in a way that avoids starving other tasks, whilst still ensuring that all of the executor’s threads are utilized.

DRM session keep-alive

ExoPlayer has long had a limitation where DRM sessions were released when playback transitioned from protected content to a clear ad break. When transitioning back to protected content, the player would need to open a new session and issue a new key request to the license server. This caused two problems:

  1. A short re-buffer whilst the key request was performed.
  2. For live content, all clients would make key requests at approximately the same time at the end of each ad break, causing spikes in request load for the license server.

In ExoPlayer 2.12, we now keep DRM sessions alive for up to 5 minutes after they were last used. This keep-alive time is configurable using DefaultDrmSessionManager.Builder.setSessionKeepaliveMs (and can also be disabled using the same method). This allows DRM sessions to be reused across clear ad breaks, solving the problems listed above.

And much more

There’s a lot more in the 2.12 release than just the features highlighted above. Other improvements include:

  • Reduced startup latency for playback of progressive streams. This has been achieved by optimizing the order in which we check the stream against possible container types, so that those that can be checked most efficiently are tried first. The stream’s file extension and MIME type are also used as hints to further optimize the ordering.
  • Support for Dolby Vision in Matroska. This is a great example of an external contribution to the project from the wider community. Thanks to all those who contributed to the issue and pull request.
  • Precise index-based seeking in MP3 files. This type of seeking scans the file to build up a time-to-byte mapping in the player. This mapping can then be used for accurate seeking instead of any mapping specified in the header of the file, which can often be imprecise. Since this method of seeking is less efficient for large MP3 files, it’s disabled by default. You can enable it with the MP3 extractor’s FLAG_ENABLE_INDEX_SEEKING, as described in the developer guide.
  • A new MetadataRetriever class to retrieve information about the format and the metadata of a media file. To use it, call one of the retrieveMetadata methods in MetadataRetriever and check out the result!

This blog post has scratched the surface of what’s new in ExoPlayer 2.12. We recommend taking a look at the full release notes. The developer guide has also been updated for this release.

As always, please feel free to get in touch via our issue tracker if you have any questions or encounter problems with the new release. Thanks for reading!

--

--