0

I am using the spotify sdk in order to search and play songs. I have my own way of searching for songs since the sdk is not finished. The sdk does provide a player object which allows you to pass a song uri to it in order to play a song. There is also a method of the player object called queue(). It is supposed to let you add songs to it and when the song finishes it plays the next one. I can add the song to the queue, as seen below:

mPlayer.queue(new OperationCallback() {
    @Override
    public void onSuccess() {
        Toast.makeText(SoundspaceActivity.this, "Added to queue!", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onError(Error error) {

    }
}, songUris.get(i));

I get the success toast message, but when the song ends nothing happens. Is there something I should do in order for the next song to be played automatically?

Here is a link to the developer page: https://spotify.github.io/android-sdk/player/

Michael
  • 3,093
  • 7
  • 39
  • 83

1 Answers1

0

You can use the onPlaybackEvent class like so:

  @Override
    public void onPlaybackEvent(PlayerEvent playerEvent) {
    Log.d("MainActivity", "Playback event received: " + 
    playerEvent.name());
    switch (playerEvent) {
        // Handle event type as necessary
        default:
            break;
        case kSpPlaybackNotifyAudioDeliveryDone:

            mPlayer.skipToNext(null);



 }
}
Joran Dob
  • 330
  • 5
  • 19