use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class PlayerService method clonePlayer.
/**
* Creates and returns a clone of the given player.
*
* @param playerId The ID of the player to clone.
* @return The cloned player.
*/
public Player clonePlayer(String playerId) {
Player player = getPlayerById(playerId);
if (player.getName() != null) {
player.setName(player.getName() + " (copy)");
}
createPlayer(player);
return player;
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class PlayerService method getNonRestPlayerByIpAddressAndUsername.
/**
* Returns the (non-REST) player with the given IP address and username. If no username is given, only IP address is
* used as search criteria.
*
* @param ipAddress The IP address.
* @param username The remote user.
* @return The player with the given IP address, or <code>null</code> if no such player exists.
*/
private Player getNonRestPlayerByIpAddressAndUsername(final String ipAddress, final String username) {
if (ipAddress == null) {
return null;
}
for (Player player : getAllPlayers()) {
boolean isRest = player.getClientId() != null;
boolean ipMatches = ipAddress.equals(player.getIpAddress());
boolean userMatches = username == null || username.equals(player.getUsername());
if (!isRest && ipMatches && userMatches) {
return player;
}
}
return null;
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class ShareManagementController method getMediaFiles.
private List<MediaFile> getMediaFiles(HttpServletRequest request) throws Exception {
Integer id = ServletRequestUtils.getIntParameter(request, "id");
String playerId = request.getParameter("player");
Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
List<MediaFile> result = new ArrayList<>();
if (id != null) {
MediaFile album = mediaFileService.getMediaFile(id);
int[] indexes = ServletRequestUtils.getIntParameters(request, "i");
if (indexes.length == 0) {
return Arrays.asList(album);
}
List<MediaFile> children = mediaFileService.getChildrenOf(album, true, false, true);
for (int index : indexes) {
result.add(children.get(index));
}
} else if (playerId != null) {
Player player = playerService.getPlayerById(playerId);
PlayQueue playQueue = player.getPlayQueue();
result = playQueue.getFiles();
} else if (playlistId != null) {
result = playlistService.getFilesInPlaylist(playlistId);
}
return result;
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class NowPlayingController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Player player = playerService.getPlayer(request, response);
List<TransferStatus> statuses = statusService.getStreamStatusesForPlayer(player);
MediaFile current = statuses.isEmpty() ? null : mediaFileService.getMediaFile(statuses.get(0).getFile());
MediaFile dir = current == null ? null : mediaFileService.getParentOf(current);
String url;
if (dir != null && !mediaFileService.isRoot(dir)) {
url = "main.view?id=" + dir.getId();
} else {
url = "home.view";
}
return new ModelAndView(new RedirectView(url));
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class PlayQueueController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
Player player = playerService.getPlayer(request, response);
Map<String, Object> map = new HashMap<>();
map.put("user", user);
map.put("player", player);
map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
map.put("visibility", userSettings.getPlaylistVisibility());
map.put("partyMode", userSettings.isPartyModeEnabled());
map.put("notify", userSettings.isSongNotificationEnabled());
map.put("autoHide", userSettings.isAutoHidePlayQueue());
return new ModelAndView("playQueue", "model", map);
}
Aggregations