Jetpack Media3 is the new home for media libraries that enables Android apps to display rich audio and visual experiences. Media3 offers a simple architecture with powerful customization, reliability, and optimizations based on device capabilities to abstract away the complexity that comes with fragmentation.
This document provides an introduction to key APIs for implementing playback and editing use-cases with Media3.
Playback Components
Media3 offers several key components for playback use-cases. The classes that make up these components will be familiar to you if you have worked with previous Android media libraries.
The following diagram demonstrates how these components come together in a typical app.
![The different components of a media app that uses Media3 connect
together in several simple ways owing to their sharing of interfaces
and classes.](https://developer.android.com/static/guide/topics/media/images/overview.png?authuser=7)
The media player
A media player is a component of your app that allows playback of media files. In Media3, you'll find:
Class | Description | Implementation note |
---|---|---|
Player |
Player is an interface that defines traditional high-level
capabilities for a media player, such as the ability to play, pause,
and seek.
|
In Media3, the Player interface is a common API implemented
or used by several components, including MediaSession and
MediaController , for example.
|
ExoPlayer |
ExoPlayer is the default implementation of the
Player interface in Media3.
|
Learn more about Media3 ExoPlayer
The media session
A media session provides a universal way to interact with a media player. This enables an app to advertise media playback to external sources and to receive playback control requests from external sources. In Media3, you'll find:
Class | Description | Implementation note |
---|---|---|
MediaSession |
Media sessions enable your app to interact with an audio or video player. They advertise media playback externally and receive playback commands from external sources. |
In Media3, a MediaSession needs a Player to
execute commands and obtain the current state.
|
MediaSessionService |
The MediaSessionService holds a media session and its
associated player in a service separate from your app's main
Activity to facilitate background playback.
|
|
MediaController |
The MediaController class is generally used to send commands
from outside your app, for example from other apps or the system itself.
The commands are sent to the underlying Player of the
associated MediaSession .
|
The MediaController class implements the Player
interface, but when calling a method the command gets sent to the
connected MediaSession . Client apps like Google Assistant
can use MediaController to control playback in a connected
session.
|
MediaLibraryService |
A MediaLibraryService is similar to a
MediaSessionService , except that it includes additional
APIs so you can serve your content library to client apps.
|
|
MediaBrowser |
The MediaBrowser class allows the user to navigate through
a media app's content library and select which items to play.
|
The MediaBrowser class implements both the
MediaController and Player interfaces. Similar to
MediaController , client apps such as Android Auto generally
implement MediaBrowser .
|
Learn more about Media3 MediaSession
The UI components
Media3 provides default UI components for viewing video and controlling playback.
Class | Description | Implementation note |
---|---|---|
PlayerView |
A default View to show video and playback controls.
|
Connects to ExoPlayer , MediaController or any
other custom Player .
|
Editing components
Media3 includes the Transformer APIs for media editing use-cases, including:
- Audio and video processing, such as adding filters and effects
- Handling special formats, such as HDR video and slow-motion video
- Composition, such as combining multiple input files
- Exporting the final output to a file
Class | Description | Implementation note |
---|---|---|
Transformer |
Use the Transformer class to start and stop transformations
and to check for progress updates on a running transformation.
|
|
Effects |
An Effects object is a collection of audio and video effects
to apply to a media item.
|
|
EditedMediaItem |
An EditedMediaItem represents a media item to process and
the edits to apply to it.
|
You can use ExoPlayer to preview the effects added to a media
item before starting the export process.
|
Learn more about Media3 Transformer
Introduction video
See the video below for an introduction to Media3 from the engineers who built it.
Useful links
- Media Developer Center
ExoPlayer
docs- Migration guide
- AndroidX Media3 on GitHub
- Media3 media session sample app
- Universal Android Music Player sample app