
This change moves the handling of any media button event into `MediaSessionImpl.onMediaButtonEvent(intent)`. This includes the double click handling from `MediaSessionLegacyStub`. The advantage is that everything is in one place which allows to offer `MediaSession.Callback.onMediaButtonEvent` with which an app can override the default implementation and handle media buttons in a custom way. Media button events can originate from various places: - Delivered to `MediaSessionService.onStartCommand(Intent)` - A `PendingIntent` from the notification below API 33 - An `Intent` sent to the `MediaButtonReceiver` by the system dispatched to the service - Delivered to `MediaSessionCompat.Callback.onMediaButtonEvent(Intent)` implemented by `MediaSessionLegacyStub` during the session is active - Bluetooth (headset/remote control) - Apps/system using `AudioManager.dispatchKeyEvent(KeyEvent)` - Apps/system using `MediaControllerCompat.dispatchKeyEvent(keyEvent)` Issue: androidx/media#12 Issue: androidx/media#159 Issue: androidx/media#216 Issue: androidx/media#249 #minor-release PiperOrigin-RevId: 575231251
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.