
Once a controller bound to a MediaSessionService unbinds, this service may be destroyed immediately if this was the last bound controller and the service isn't started in the foreground. At the time of releasing the controller, there may still be pending commands that need to be handled by the session service. These commands may cause the session service to post a foreground notification to keep it alive. So to avoid the destruction of the service while these commands are still handled, we need to keep the controller bound. We also add a timeout in case the session tasks are never completed by the session implementation. In case the controller is destroyed, the unbinding happens automatically by the system. PiperOrigin-RevId: 463802220 (cherry picked from commit ac42b593cc3280b866d42cdc11d57bb031b39757)
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.