diff --git a/airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java b/airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java index b24b03be..f3a1e7de 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java @@ -252,6 +252,33 @@ public class PlayQueueService { return doPlayInternetRadio(request, player, radio).setStartPlayerAt(0); } + /** + * @param index Start playing at this index, or play whole playlist if {@code null}. + */ + public PlayQueueInfo addPlaylist(int id, Integer index) throws Exception { + HttpServletRequest request = WebContextFactory.get().getHttpServletRequest(); + HttpServletResponse response = WebContextFactory.get().getHttpServletResponse(); + + String username = securityService.getCurrentUsername(request); + boolean queueFollowingSongs = settingsService.getUserSettings(username).isQueueFollowingSongs(); + + List files = playlistService.getFilesInPlaylist(id, true); + if (!files.isEmpty() && index != null) { + if (queueFollowingSongs) { + files = files.subList(index, files.size()); + } else { + files = Arrays.asList(files.get(index)); + } + } + + // Remove non-present files + files.removeIf(file -> !file.isPresent()); + + // Add to the play queue + int[] ids = files.stream().mapToInt(f -> f.getId()).toArray(); + return doAdd(request, response, ids, index); + } + /** * @param index Start playing at this index, or play whole playlist if {@code null}. */ @@ -273,6 +300,8 @@ public class PlayQueueService { // Remove non-present files files.removeIf(file -> !file.isPresent()); + + // Play now Player player = getCurrentPlayer(request, response); return doPlay(request, player, files).setStartPlayerAt(0); } diff --git a/airsonic-main/src/main/webapp/WEB-INF/jsp/coverArt.jsp b/airsonic-main/src/main/webapp/WEB-INF/jsp/coverArt.jsp index baa44859..86a55200 100644 --- a/airsonic-main/src/main/webapp/WEB-INF/jsp/coverArt.jsp +++ b/airsonic-main/src/main/webapp/WEB-INF/jsp/coverArt.jsp @@ -76,7 +76,7 @@ PARAMETERS style="position: relative; top: 8px; left: 8px; z-index: 2; display:none" > - +
@@ -154,5 +154,8 @@ PARAMETERS top.playQueue.onAdd(${param.albumId}); + + top.playQueue.onAddPlaylist(${param.playlistId}); + }); diff --git a/airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp b/airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp index 1b37f4ce..7a0bb778 100644 --- a/airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp +++ b/airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp @@ -380,6 +380,9 @@ function onAddNext(id) { playQueueService.addAt(id, getCurrentSongIndex() + 1, playQueueCallback); } + function onAddPlaylist(id, index) { + playQueueService.addPlaylist(id, index, playQueueCallback); + } function onShuffle() { playQueueService.shuffle(playQueueCallback); } diff --git a/airsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp b/airsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp index f2cbdf15..9c332949 100644 --- a/airsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp +++ b/airsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp @@ -134,6 +134,9 @@ function onPlayAll() { top.playQueue.onPlayPlaylist(playlist.id); } + function onAddAll() { + top.playQueue.onAddPlaylist(playlist.id); + } function onAdd(index) { top.playQueue.onAdd(songs[index].id); $().toastmessage('showSuccessToast', '') @@ -184,7 +187,8 @@

» ${fn:escapeXml(model.playlist.name)}

- + | +