diff options
author | manthole <67294267+manthole@users.noreply.github.com> | 2021-06-27 23:10:38 +0200 |
---|---|---|
committer | manthole <67294267+manthole@users.noreply.github.com> | 2021-06-27 23:10:38 +0200 |
commit | 2b592b4986b92c85150ecb9d08a521e6391cc160 (patch) | |
tree | c362cbda05a1e1d44fff9e477e6b90c370d724eb /src/main/java/musichub/business/MusicHub.java | |
parent | 22d53407aa128c3e3019733ddcbd3bb6dd5541bf (diff) |
Add new feature - display playlist
Diffstat (limited to 'src/main/java/musichub/business/MusicHub.java')
-rw-r--r-- | src/main/java/musichub/business/MusicHub.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/musichub/business/MusicHub.java b/src/main/java/musichub/business/MusicHub.java index 660f0f8..f6805b6 100644 --- a/src/main/java/musichub/business/MusicHub.java +++ b/src/main/java/musichub/business/MusicHub.java @@ -359,5 +359,33 @@ public class MusicHub { this.getAudioElement(searchResult, searchResult.get(0).getTitle()); } } + public String getPlayListsTitles() { + StringBuilder titleList = new StringBuilder(); + for (PlayList pl : playlists) + titleList.append(pl.getTitle()).append("\n"); + return titleList.toString(); + } + + public List<AudioElement> getPlayListSongs(String playListTitle) throws NoPlayListFoundException { + PlayList thePlayList = null; + ArrayList<AudioElement> songsInPlayList = new ArrayList<>(); + for (PlayList pl : playlists) { + if (pl.getTitle().equalsIgnoreCase(playListTitle)) { + thePlayList = pl; + break; + } + } + if (thePlayList == null) throw new NoPlayListFoundException("No playlist with this title in the MusicHub!"); + + List<UUID> songIDs = thePlayList.getElements(); + for (UUID id : songIDs) + for (AudioElement el : elements) { + if (el instanceof Song) { + if (el.getUUID().equals(id)) songsInPlayList.add(el); + } + } + return songsInPlayList; + + } }
\ No newline at end of file |