ExoPlayer 2.14 - What’s new

Olly Woodman
AndroidX Media3
Published in
3 min readMay 17, 2021

ExoPlayer 2.14 contains many new features, improvements and bug fixes. This post highlights some of the most significant changes. As always, we recommend also taking a look at the full release notes.

RTSP

ExoPlayer 2.14 includes support for streaming over RTSP. This initial version supports RTSP version 1.0, H.264 video, and both AAC and AC3 audio. Unicast streaming over both UDP and TCP (RTP over RTSP) is supported. Multicast is not yet supported.

To play an RTSP stream, you need to depend on the RTSP module.

implementation ‘com.google.android.exoplayer:exoplayer-rtsp:2.X.X’

It’s then as simple as creating a MediaItem for an RTSP URI and passing it to the player.

// Create a player instance.
SimpleExoPlayer player =
new SimpleExoPlayer.Builder(context)
.build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(rtspUri));
// Prepare the player.
player.prepare();

To learn more, see the RTSP page of our developer guide.

DRM key prefetching

Transitions to protected content will be smoother in ExoPlayer 2.14. This includes transitions from clear to protected content, transitions from one piece of protected content to another, and transitions within pieces of protected content that use key rotation.

The improvement is thanks to a change in the way DRM key requests are made. Previous versions of ExoPlayer would perform a key request at the point of playback transitioning to the piece of content for which keys are required. This would introduce a short pause in playback whilst the key request was completed. In ExoPlayer 2.14, key requests are made when the piece of content starts to be buffered. This happens in advance, meaning keys are already prefetched when playback transitions to the content for which they’re required. This means the short pause is eliminated and playback can transition smoothly into the protected content.

Key prefetching will be automatically enabled for all apps using ExoPlayer’s DefaultDrmSessionManager. Apps that provide a custom DrmSessionManager will need to implement the new DrmSessionManager.preacquireSession method to enable prefetching, paying careful attention to the thread-safety requirements.

Subtitles

ExoPlayer 2.14(*) adds additional styling features for TTML and Substation Alpha (SSA/ASS) subtitles. These improvements were all made by external contributors, and we’d like to thank @dlafayet, @szaboa and @abeljim for their contributions.

The TTML improvements by @dlafayet build on the support for Japanese subtitle features that we added in 2.12, adding support for shear, textEmphasis and ebutts:multiRowAlign attributes, as well as fixing some pre-existing bugs. As with the features added in 2.12, rendering support with ExoPlayer’s UI components requires opting-in by passing VIEW_TYPE_WEB to SubtitleView.setViewType().

@szaboa and @abeljim have added support for bold, italic, underline, strikethrough, font size and color in SSA subtitles. Support for more SSA styling is tracked by Issue #8435.

(*) Some of these improvements were included in the 2.13.2 and 2.13.3 minor releases.

Player interface

The Player interface has been simplified by promoting the most frequently used audio, video and subtitle methods so that they’re defined directly by the interface, rather than by indirect component interfaces. Similarly, a unified Player.Listener has been added, instances of which can be registered by calling Player.addListener.

It’s also possible to query which commands can be executed on a Player. Available commands can be queried using Player.isCommandAvailable and Player.getAvailableCommands. Changes in the available commands are reported via Listener.onAvailableCommandsChanged.

Finally, structured MediaMetadata is exposed via a new Player.getMediaMetadata method. This makes it simpler to access common metadata such as title and artist, if the media defines them. Changes in media metadata are reported via Listener.onMediaMetadataChanged. We will be adding additional fields to MediaMetadata in future releases.

As always, we recommend taking a look at the full release notes. 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!

p.s., we’re hiring!

--

--