uamp
uamp copied to clipboard
How to update MusicService playlist properly?
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] -
JsonSourceclass take this list as Input, then doing the conversion to respective model - Added a
MediaSessionReceiverto theMediaSessionConnectorin the service class and Send custom action usingMediaControllerCompat.TransportControlsbut theMediaSessionReceivernever called - So, I have sent command to service class using
MusicServiceConnection.sendCommand()and in the service class received command onMediaSessionConnector.PlaybackPreparer.onCommand() - After getting the command, I'm trying to set a different list of
SongDataModelby updatingJsonSource& 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
MusicServiceclass - If condition matched, stop the
Music Serviceand clear the instance ofMusicServiceConnection - Then create new instance of
MusicServiceConnectionand setup everything again, but it throws exceptionjava.lang.IllegalStateException: getRoot() called while not connected (state=CONNECT_STATE_CONNECTING)which is totally valid.