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 | Playeris an interface that defines traditional high-level
      capabilities for a media player, such as the ability to play, pause,
      and seek. | In Media3, the Playerinterface is a common API implemented
      or used by several components, includingMediaSessionandMediaController, for example. | 
| ExoPlayer | ExoPlayeris the default implementation of thePlayerinterface 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 MediaSessionneeds aPlayerto
      execute commands and obtain the current state. | 
| MediaSessionService | The MediaSessionServiceholds a media session and its
      associated player in a service separate from your app's mainActivityto facilitate background playback. | |
| MediaController | The MediaControllerclass 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 underlyingPlayerof the
      associatedMediaSession. | The MediaControllerclass implements thePlayerinterface, but when calling a method, theMediaControllersends
      the command sent to the
      connectedMediaSession. Client apps like Google Assistant
      can useMediaControllerto control playback in a connected
      session. | 
| MediaLibraryService | A MediaLibraryServiceis similar to aMediaSessionService, except that it includes additional
      APIs so you can serve your content library to client apps. | |
| MediaBrowser | The MediaBrowserclass allows the user to navigate through
      a media app's content library and select which items to play. | The MediaBrowserclass implements both theMediaControllerandPlayerinterfaces. Similar toMediaController, client apps such as Android Auto generally
      implementMediaBrowser. | 
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 Viewto show video and playback controls. | Connects to ExoPlayer,MediaControlleror any
      other customPlayer. | 
| PlayerSurface | A Composable representing a dedicated drawing Surfaceto show video. | Connects to any Player, but does not contain playback controls.
      Only used for rendering of frames and can be resized according to various
      
      ContentScaletypes. This and many other composables can be
      found in the Compose UI utilities. | 
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 Transformerclass to start and stop transformations
      and to check for progress updates on a running transformation. | |
| Effects | An Effectsobject is a collection of audio and video effects
      to apply to a media item. | You can use ExoPlayerto preview the effects added to a media
      item before starting the export process. | 
| EditedMediaItem | An EditedMediaItemrepresents a media item to process and
      the edits to apply to it. | 
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
- ExoPlayerdocs
- Migration guide
- AndroidX Media3 on GitHub
- Media3 media session sample app
- Universal Android Music Player sample app
