
A fatal `PlaybackException` is mapped to a legacy playback state in state `STATE_ERROR` with error code, message and extras. A non-fatal error sent to controllers with `MediaSession.sendError` is synced to the legacy session by setting error code and message and merging the extras while preserving the rest of the state in sync with the session player. Vice versa, a `MediaController` connected to a legacy session receives fatal errors through `Player.onPlayerErrorChanged()` and non-fatal errors through `MediaController.Listener.onError()`. Error codes are mapped in `LegacyConversions`. Values of error codes in `@SessionError.ErrorCode` come from `@PlaybackExceptino.ErrorCode` with the exception of `@SessionError.ERROR_IO` and `@SessionError.ERROR_UNKNOWN`. These already exist in `@PlaybackException.ErrorCode` and are mapped accordingly to avoid semantic duplicates. PiperOrigin-RevId: 642595517
Session module
This module provides media session functionality through which media information and controls can be exposed to the Android platform, as well as to other processes and applications.
Getting the module
The easiest way to get the module is to add it as a gradle dependency:
implementation 'androidx.media3:media3-session:1.X.X'
where 1.X.X
is the version, which must match the version of the other media
modules being used.
Alternatively, you can clone this GitHub project and depend on the module locally. Instructions for doing this can be found in the top level README.