I have not messed with the player state yet too much (only grabbing cover art uri), but here is how I would go about it off the top of my head.
I would first subscribe to the player state to see what is going on with the player. If it is paused, I would then play the album you were talking about or want to talk about. Here is a small example that might be helpful.
SpotifyAppRemote mSpotifyAppRemote; // The app remote
/* For mAppRemoteSet the connection parameters */
connectionParams = new ConnectionParams.Builder(CLIENT_ID)
.setRedirectUri(REDIRECT_URI)
.showAuthView(true)
.build();
/* Connect to SpotifyAppRemote */
SpotifyAppRemote.connect(this, connectionParams, new Connector.ConnectionListener() {
@Override
public void onConnected(SpotifyAppRemote spotifyAppRemote) {
mSpotifyAppRemote = spotifyAppRemote;
Log.d(TAG, "App remote Connected!");
connected();
@Override
public void onFailure(Throwable throwable) {
Log.e(TAG, throwable.getMessage(), throwable);
// Hanfle errors here
}
});
}
public connected() {
/* Subscribe to the PlayerState */
mSpotifyAppRemote.getPlayerApi()
.subscribeToPlayerState()
.setEventCallback(playerState -> {
if (playerState.isPaused) {
mSpotifyAppRemote.getPlayerApi().play("ALBUM URI");
}
});
}
Where "CLIENT_ID" and "REDIRECT_URI" are specific to what you defined in your code already from the dashboard.
Where "ALBUM URI" is the id specific to that album you want to play after you play the first song you mentioned.
You can also play the specific track then set the offset of the album to the beginning and start the whole album over if the specific track is in the middle, end, etc of the album.
I am still learning the sdk and the many options it offers so I apologize ahead of time if this is completely irrelevant or unhelpful.