Gyome
Gyome

Reputation: 1333

[deezer][android] Track not playing when acting on PLAYING PlayerState

I'm using the android Deezer SDK 0.10.16 to play tracks, but I have a strange bug. If i add a playerStateChangeListener on the TrackPlayer and do some UI changes on the event PlayerState.PLAYING (like changing a text or showing a toast), the track will never start and I receive no notification of any error going on.

         mDeezerPlayer.addOnPlayerStateChangeListener(new OnPlayerStateChangeListener() {
            @Override
            public void onPlayerStateChange(com.deezer.sdk.player.event.PlayerState playerState, long l) {

                if(mEventListener != null) {
                    [...]
                    if (playerState.equals(com.deezer.sdk.player.event.PlayerState.PLAYING)) { //TODO is this equal to resume?
                        mEventListener.onPlayerResume(); //WARNING if we message a toast during the first PLAYING event the track does not start
                    } 
                    [...]
                }
            }
        });

FYI, the player is in a service, communicating through my listener to an activity. I can do UI changes on the other PlayerState events, but not on the first PLAYING.

Is this a bug of the SDK or am I doing something wrong? Thanks

Upvotes: 0

Views: 235

Answers (1)

XGouchet
XGouchet

Reputation: 10203

Indeed, there's an issue in the SDK : the PLAYING state is triggered on the background thread. Modifying the UI on this event crashes the thread and prevent the track from playing.

In the future, the PLAYING state event will be triggered on the main thread to allow UI events.

Upvotes: 1

Related Questions