Skip to content

Commit

Permalink
edits spotify player, error handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrence Onodipe committed Apr 21, 2024
1 parent a421956 commit 191e4d9
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ public void onConnected(@NonNull SpotifyAppRemote spotifyAppRemote) {
Log.d("MainActivity", "Connected to Spotify!");

// Now you can use mSpotifyAppRemote to control playback, etc.
playTrack("spotify:track:4uLU6hMCjMI75M1A2tKUQC");
}

@Override
public void onFailure(Throwable throwable) {
Log.e("MainActivity", "Failed to connect to Spotify", throwable);
// Handle connection failure
public void onFailure(Throwable error) {
Log.e("MainActivity", "Failed to connect to Spotify", error);
// Handle connection failure here
}
});
obj.getPlayerApi().play("spotify:track:4uLU6hMCjMI75M1A2tKUQC");



topLabel = (TextView) findViewById(R.id.topLabel);
topLabel.setText("Top Tracks!");
Expand All @@ -89,7 +91,14 @@ public void onFailure(Throwable throwable) {
storiesProgressView.startStories(); // <- start progress
}


private void playTrack (String trackUri) {
if (obj != null && obj.isConnected()) {
obj.getPlayerApi().play(trackUri);
} else {
Log.e("MainActivity", "Cannot play track: Spotify connection not established or disconnected.");
// Handle the case where Spotify connection is not established or disconnected
}
}
@Override
public void onNext() {
currentIndex++;
Expand Down

0 comments on commit 191e4d9

Please sign in to comment.