Merge remote-tracking branch 'origin/pr/1433'

master
Andrew DeMaria 5 years ago
commit 2f75254010
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 29
      airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java
  2. 5
      airsonic-main/src/main/webapp/WEB-INF/jsp/coverArt.jsp
  3. 3
      airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp
  4. 6
      airsonic-main/src/main/webapp/WEB-INF/jsp/playlist.jsp

@ -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<MediaFile> 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);
}

@ -76,7 +76,7 @@ PARAMETERS
style="position: relative; top: 8px; left: 8px; z-index: 2; display:none" >
</div>
<c:if test="${not empty param.albumId}">
<c:if test="${not empty param.albumId or not empty param.playlistId}">
<div style="position: relative; width: 0; height: 0">
<img alt="Add overlay" src="<spring:theme code='addOverlayImage'/>" id="${addId}"
style="position: relative; top: 8px; left: 48px; z-index: 2; display:none" >
@ -154,5 +154,8 @@ PARAMETERS
<c:if test="${not empty param.albumId}">
top.playQueue.onAdd(${param.albumId});
</c:if>
<c:if test="${not empty param.playlistId}">
top.playQueue.onAddPlaylist(${param.playlistId});
</c:if>
});
</script>

@ -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);
}

@ -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', '<fmt:message key="main.addlast.toast"/>')
@ -184,7 +187,8 @@
<h1><a href="playlists.view"><fmt:message key="left.playlists"/></a> &raquo; <span id="name">${fn:escapeXml(model.playlist.name)}</span></h1>
<h2>
<span class="header"><a href="javascript:void(0)" onclick="onPlayAll();"><fmt:message key="common.play"/></a></span>
<span class="header"><a href="javascript:onPlayAll()"><fmt:message key="common.play"/></a></span> |
<span class="header"><a href="javascript:onAddAll()"><fmt:message key="main.addall"/></a></span>
<c:if test="${model.user.downloadRole}">
<c:url value="download.view" var="downloadUrl"><c:param name="playlist" value="${model.playlist.id}"/></c:url>

Loading…
Cancel
Save