uamp icon indicating copy to clipboard operation
uamp copied to clipboard

How to update MusicService playlist properly?

Open rommansabbir opened this issue 4 years ago • 0 comments

My Scenario:

  • I want to keep only one playlist on MusicService
  • Based on user action I want to set another list as the primary list for MusicService

How I tried to achieve this by:

  • Made a static list of SongDataModel [That's my POJO/Parse Object (Subclass), using ParseSDK]
  • JsonSource class take this list as Input, then doing the conversion to respective model
  • Added a MediaSessionReceiver to the MediaSessionConnector in the service class and Send custom action using MediaControllerCompat.TransportControls but the MediaSessionReceiver never called
  • So, I have sent command to service class using MusicServiceConnection.sendCommand() and in the service class received command on MediaSessionConnector.PlaybackPreparer.onCommand()
  • After getting the command, I'm trying to set a different list of SongDataModel by updating JsonSource & it's correspondent but wasn't able to get what I wanted to achieve.

Another approach I tried:

  • Check if the static song source is the same or not in MusicService class
  • If condition matched, stop the Music Service and clear the instance of MusicServiceConnection
  • Then create new instance of MusicServiceConnection and setup everything again, but it throws exception java.lang.IllegalStateException: getRoot() called while not connected (state=CONNECT_STATE_CONNECTING) which is totally valid.

rommansabbir avatar May 29 '21 09:05 rommansabbir