Basically, I have a music player and I want it to auto play the next song after the first song finishes. This is what I coded so far but am not sure what more to add so that it works. I've tried to call the method that plays the next song but it gave me a parameter error. Why is that so?
private void gracefullyStopWhenMusicEnds() {
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
next(view);
}
});
}
public void next(View view)
{
Song nextSong = SongCollection.getNextSong(songId);
if ( nextSong != null)
{
songId = nextSong.getId();
title = nextSong.getTitle();
artist = nextSong.getArtist();
fileLink = nextSong.getFileLink();
coverArt = nextSong.getCoverArt();
url = BASE_URL + fileLink;
displaySong(title,artist,coverArt);
stopActivities();
playOrPauseMusic(view);
}
}
Thanks for any help given.