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.
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 media player
A media player is a component of your app that allows playback of media files. In Media3, you'll find:
Player is an interface that defines traditional high-level
capabilities for a media player, such as the ability to play, pause,
In Media3, the
Player interface is a common API implemented
or used by several components, including
MediaController, for example.
ExoPlayer is the default implementation of the
Player interface in Media3.
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:
|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
execute commands and obtain the current state.
MediaSessionService holds a media session and its
associated player in a service separate from your app's main
Activity to facilitate background playback.
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
MediaController class implements the
interface, but when calling a method the command gets sent to the
MediaSession. Client apps like Google Assistant
MediaController to control playback in a connected
MediaLibraryService is similar to a
MediaSessionService, except that it includes additional
APIs so you can serve your content library to client apps.
MediaBrowser class allows the user to navigate through
a media app's content library and select which items to play.
MediaBrowser class implements both the
Player interfaces. Similar to
MediaController, client apps such as Android Auto generally
The UI components
Media3 provides default UI components for viewing video and controlling playback.
View to show video and playback controls.
MediaController or any
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
Transformer class to start and stop transformations
and to check for progress updates on a running transformation.
Effects object is a collection of audio and video effects
to apply to a media item.
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.
See the video below for an introduction to Media3 from the engineers who built it.
- Media Developer Center
- Migration guide
- AndroidX Media3 on GitHub
- Media3 media session sample app
- Universal Android Music Player sample app