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 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 MediaController sends
the command 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.
|
|