Sample background playback - devrath/MediaAlchemySuite GitHub Wiki
Step-1-Connect the player with the session
Here we prepare the Exoplayer instance
Pass its instance to the MediaSession and create a session instance
There is no need to handle the callbacks using the connector since it is taken care of by the library internally
// Prepare the player instance
player =Exoplayer.Builder(context).build()
// Prepare the media session
mediaSession =MediaSession.Builder(context,player).build()
Step-2-Connect MediaController to the MediaSession Service
In the Activity where we will display the UI, We need to establish the link to the session in the onStart() method.
val sessionToken =SessionToken(/* ... */PlayerService.class::java)
mediaControllerFuture =MediaController.Builder(context, sessionToken).buildAsync()