Published in


ExoPlayer 2 - New package and class names

As ExoPlayer 2 nears completion, we’ve taken some time to reorganize the library.

New root package name

ExoPlayer 2 has a new root package name: This reflects the fact that the V2 release is a significant departure from its predecessor. More importantly, it allows developers to use both V1 and V2 in a single project without any naming conflicts. This is important for a couple of use cases:

  • In order to mitigate risk when moving to ExoPlayer 2, a developer may wish to ship a version of their application that includes both V1 and V2, and control from their server which player is used for each playback. This allows use of V2 to be ramped up gradually, and ramped down again if a problem is encountered. Whilst Play Store’s staged rollout feature can be used to achieve a similar result, it is a less flexible approach.
  • Applications that use ExoPlayer for multiple features can be migrated to V2 one feature at a time, rather than in a single step.

Sanitized package structure and class names

In addition to the new root package name, we’ve sanitized the package structure and class names used throughout the library. Some of the highlights to look out for when moving from V1 to V2 are listed below.

Disclaimer: Links below are hardcoded to the latest snapshot of ExoPlayer 2 at the time of writing, and will grow stale over time.

  • Renderer replaces the old TrackRenderer class. It also becomes an interface, making it easier to write custom implementations from scratch. An abstract BaseRenderer class contains the functionality previously found in TrackRenderer.
  • A new MediaSource interface defines media for ExoPlayer to play. A MediaSource can expose multiple MediaPeriods, from which SampleStreams can be obtained. A MediaPeriod can be thought of a single item in a larger playlist of items. A SampleStream is a stream of media samples (and associated format information) that can be consumed by a Renderer. Together, MediaSource, MediaPeriod and SampleStream replace the old SampleSource interface. There are concrete MediaSource implementations for DASH, SmoothStreaming, HLS and regular media files, all of which are in a new source package.
  • Exoplayer 1 had a util.extensions package defining a Decoder interface, that was implemented by each of ExoPlayer’s software decoder extensions. In ExoPlayer 2 this package is promoted to a new decoder package. It’s also used more widely throughout the library. What were previously SubtitleParsers are now SubtitleDecoders, with SubtitleDecoder extending Decoder. MetadataParser has been renamed MetadataDecoder, with a plan to have it extend Decoder too.
  • ExoPlayer’s MediaCodecAudioRenderer and MediaCodecVideoRenderer renderers are located in new audio and video packages in V2. Their common base class has been relocated to a new mediacodec package.
  • FrameworkSampleSource has been removed. It has long been deprecated and will not be retained in V2.
  • ExoPlayer 1 featured two classes for describing media formats: Format and MediaFormat. In V2 sanity is restored, with a single Format class used everywhere!

In summary, much has changed in ExoPlayer 2. It may take some time to adjust, however we hope that the new package and class structure will be an improvement going forward.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Olly Woodman

Olly Woodman

More from Medium

Security in Android 12 — For Developers

Tried making bubbles

Build Types and Product Flavor in Android