use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class M3UController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setContentType("audio/x-mpegurl");
response.setCharacterEncoding(StringUtil.ENCODING_UTF8);
Player player = playerService.getPlayer(request, response);
String url = NetworkService.getBaseUrl(request);
url = url + "ext/stream?";
if (player.isExternalWithPlaylist()) {
createClientSidePlaylist(response.getWriter(), player, url);
} else {
createServerSidePlaylist(response.getWriter(), player, url);
}
return null;
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class MoreController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
String uploadDirectory = null;
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername());
if (musicFolders.size() > 0) {
uploadDirectory = new File(musicFolders.get(0).getPath(), "Incoming").getPath();
}
StringBuilder jamstashUrl = new StringBuilder("http://jamstash.com/#/settings?u=" + StringUtil.urlEncode(user.getUsername()) + "&url=");
jamstashUrl.append(StringUtil.urlEncode(NetworkService.getBaseUrl(request)));
Player player = playerService.getPlayer(request, response);
ModelAndView result = new ModelAndView();
result.addObject("model", map);
map.put("user", user);
map.put("uploadDirectory", uploadDirectory);
map.put("genres", mediaFileService.getGenres(false));
map.put("currentYear", Calendar.getInstance().get(Calendar.YEAR));
map.put("musicFolders", musicFolders);
map.put("clientSidePlaylist", player.isExternalWithPlaylist() || player.isWeb());
map.put("brand", settingsService.getBrand());
map.put("jamstashUrl", jamstashUrl);
return result;
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class PlaylistController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<>();
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
User user = securityService.getCurrentUser(request);
String username = user.getUsername();
UserSettings userSettings = settingsService.getUserSettings(username);
Player player = playerService.getPlayer(request, response);
Playlist playlist = playlistService.getPlaylist(id);
if (playlist == null) {
return new ModelAndView(new RedirectView("notFound"));
}
map.put("playlist", playlist);
map.put("user", user);
map.put("player", player);
map.put("editAllowed", username.equals(playlist.getUsername()) || securityService.isAdmin(username));
map.put("partyMode", userSettings.isPartyModeEnabled());
return new ModelAndView("playlist", "model", map);
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class StatusService method getPlayStatuses.
public synchronized List<PlayStatus> getPlayStatuses() {
Map<String, PlayStatus> result = new LinkedHashMap<String, PlayStatus>();
for (PlayStatus remotePlay : remotePlays) {
if (!remotePlay.isExpired()) {
result.put(remotePlay.getPlayer().getId(), remotePlay);
}
}
List<TransferStatus> statuses = new ArrayList<TransferStatus>();
statuses.addAll(inactiveStreamStatuses.values());
statuses.addAll(streamStatuses);
for (TransferStatus streamStatus : statuses) {
Player player = streamStatus.getPlayer();
File file = streamStatus.getFile();
if (file == null) {
continue;
}
MediaFile mediaFile = mediaFileService.getMediaFile(file);
if (player == null || mediaFile == null) {
continue;
}
Date time = new Date(System.currentTimeMillis() - streamStatus.getMillisSinceLastUpdate());
result.put(player.getId(), new PlayStatus(mediaFile, player, time));
}
return new ArrayList<PlayStatus>(result.values());
}
use of org.libresonic.player.domain.Player in project libresonic by Libresonic.
the class PlaylistService method createPlaylistForPlayQueue.
public int createPlaylistForPlayQueue() {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
Player player = playerService.getPlayer(request, response);
Locale locale = localeResolver.resolveLocale(request);
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale);
Date now = new Date();
Playlist playlist = new Playlist();
playlist.setUsername(securityService.getCurrentUsername(request));
playlist.setCreated(now);
playlist.setChanged(now);
playlist.setShared(false);
playlist.setName(dateFormat.format(now));
playlistService.createPlaylist(playlist);
playlistService.setFilesInPlaylist(playlist.getId(), player.getPlayQueue().getFiles());
return playlist.getId();
}
Aggregations