The song informs the playlist when it has ended by calling the playingHasEnded()
ID: 3528354 • Letter: T
Question
The song informs the playlist when it has ended by calling the playingHasEnded() method. This method moves to the next song in the playlist, assuming the playlist contains additional songs what is the solutions
--------------------------------------------------------------------------------------------
public void play()
{ if (songs.size()>0) {
currentSongPlaying = 0;
state = "playing";
Mp3 song = songs.get(currentSongPlaying);
song.play(this);
}
} public void forward() {
if (state.equals("playing")) {
Mp3 song = songs.get(currentSongPlaying);
song.stop();
if (songs.size()-1>currentSongPlaying) {
currentSongPlaying = currentSongPlaying + 1;
song = songs.get(currentSongPlaying);
song.play(this);
} else if (songs.size()-1==currentSongPlaying) {
state="notPlaying";
}
}
} public void playingHasEnded() {
if ((songs.size()>currentSongPlaying) && (state.equals("playing"))) {
currentSongPlaying = currentSongPlaying + 1;
Mp3 song = songs.get(currentSongPlaying);
song.play(this);
} else if (state.equals("playing")) {
state = "notPlaying";
}
Explanation / Answer
public void play() { if (songs.size()>0) { currentSongPlaying = 0; state = "playing"; Mp3 song = songs.get(currentSongPlaying); song.play(this); } } public void forward() { if (state.equals("playing")) { Mp3 song = songs.get(currentSongPlaying); song.stop(); if (songs.size()-1>currentSongPlaying) { currentSongPlaying = currentSongPlaying + 1; song = songs.get(currentSongPlaying); song.play(this); } else if (songs.size()-1==currentSongPlaying) { state="notPlaying"; } } } public void playingHasEnded() { if ((songs.size()>currentSongPlaying) && (state.equals("playing"))) { currentSongPlaying = currentSongPlaying + 1; Mp3 song = songs.get(currentSongPlaying); song.play(this); } else if (state.equals("playing")) { state = "notPlaying"; } the code is correct what else do u want
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.