
`MediaLibraryServiceLegacyStub` handles various edge cases by calling `result.sendError(null)` with the intention to send back an error to the legacy browser [1]. `MediaBrowserServiceCompat` of the legacy media1 Compat library has an inner base class `Result` that has a default implementation of `onErrorSent` that throws an `UnsupportedOperationException` [2]. However, most anonymous inner classes for `Result` created in `MediaBrowserServiceCompat` do not override `onErrorSent` [3]. Hence Media3 must not call `sendError` in these cases. Instead we call `sendResult(null)` according to what the default implementation of the callbacks in `MediaBrowserServiceCompat` do ([4] as an example). Issue: androidx/media#78 Issue: androidx/media#334 [1] https://github.com/androidx/media/blob/release/libraries/session/src/main/java/androidx/media3/session/MediaLibraryServiceLegacyStub.java#L200 [2] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=872 [3] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=578-604?q=MediaBrowserServiceCompat&ss=androidx [4] https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:media/media/src/main/java/androidx/media/MediaBrowserServiceCompat.java;l=1395 PiperOrigin-RevId: 551210137
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.