PlaybackService
Playback service that handle background playback and Media notification for a Player.
Add this permission inside your manifest :
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
And add your PlaybackService to the application manifest as follow :
<service android:name=".YourService" android:foregroundServiceType="mediaPlayback" />
Drawbacks : Then last ServiceConnection is unbind, it kills the service. Can happen if binding to service is done inside the Activity without orientationChanges. So each time user rotate, it's kills the service.
The player is not well integrated with external service like Android Auto. Has for AndroidAuto you have to create a MediaLibraryService.
Functions
Create notification builder, can be override to customize it.
Allow MediaSession.Builder customization except MediaSession.Builder.setSessionActivity
Pending intent for MediaSession.getSessionActivity
Set player to be connected to MediaNotification and MediaSession.