|
|
@ -250,6 +250,33 @@ public class PlayQueueService { |
|
|
|
return doPlayInternetRadio(request, player, radio).setStartPlayerAt(0); |
|
|
|
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}. |
|
|
|
* @param index Start playing at this index, or play whole playlist if {@code null}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -271,6 +298,8 @@ public class PlayQueueService { |
|
|
|
|
|
|
|
|
|
|
|
// Remove non-present files
|
|
|
|
// Remove non-present files
|
|
|
|
files.removeIf(file -> !file.isPresent()); |
|
|
|
files.removeIf(file -> !file.isPresent()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Play now
|
|
|
|
Player player = getCurrentPlayer(request, response); |
|
|
|
Player player = getCurrentPlayer(request, response); |
|
|
|
return doPlay(request, player, files).setStartPlayerAt(0); |
|
|
|
return doPlay(request, player, files).setStartPlayerAt(0); |
|
|
|
} |
|
|
|
} |
|
|
|