I have to create an application for audio stream with different functionalities. I am stuck with the shuffle play action. Because on my previous project were GUI wasnt included I created this method where I created a new playlist with a different order.
But now where I have the GUI part and I need to show the playlist in a JList I cant change the original playlist. How am I supposed to get random songs when I press Next without changing the original playlist? Thank you.
public ArrayList<String> playRandom(ArrayList<String> songsPath, Player p) {
ArrayList<String> newPlaylist = new ArrayList<>();
while(songsPath.size()>0) {
String song = songsPath.get(randomIndex(songsPath.size()));
songsPath.remove(song);
newPlaylist.add(song);
}
return newPlaylist;
}
That's what I used to do but it changes the original playlist which is a problem if someone wants to go back to playing the songs in the original row.