Search in sources :

Example 1 with PlayerSettingsCommand

use of org.libresonic.player.command.PlayerSettingsCommand in project libresonic by Libresonic.

the class PlayerSettingsController method formBackingObject.

@ModelAttribute
protected void formBackingObject(HttpServletRequest request, Model model) throws Exception {
    handleRequestParameters(request);
    List<Player> players = getPlayers(request);
    User user = securityService.getCurrentUser(request);
    PlayerSettingsCommand command = new PlayerSettingsCommand();
    Player player = null;
    String playerId = request.getParameter("id");
    if (playerId != null) {
        player = playerService.getPlayerById(playerId);
    } else if (!players.isEmpty()) {
        player = players.get(0);
    }
    if (player != null) {
        command.setPlayerId(player.getId());
        command.setName(player.getName());
        command.setDescription(player.toString());
        command.setType(player.getType());
        command.setLastSeen(player.getLastSeen());
        command.setDynamicIp(player.isDynamicIp());
        command.setAutoControlEnabled(player.isAutoControlEnabled());
        command.setM3uBomEnabled(player.isM3uBomEnabled());
        command.setTranscodeSchemeName(player.getTranscodeScheme().name());
        command.setTechnologyName(player.getTechnology().name());
        command.setAllTranscodings(transcodingService.getAllTranscodings());
        List<Transcoding> activeTranscodings = transcodingService.getTranscodingsForPlayer(player);
        int[] activeTranscodingIds = new int[activeTranscodings.size()];
        for (int i = 0; i < activeTranscodings.size(); i++) {
            activeTranscodingIds[i] = activeTranscodings.get(i).getId();
        }
        command.setActiveTranscodingIds(activeTranscodingIds);
    }
    command.setTranscodingSupported(transcodingService.isDownsamplingSupported(null));
    command.setTranscodeDirectory(transcodingService.getTranscodeDirectory().getPath());
    command.setTranscodeSchemes(TranscodeScheme.values());
    command.setTechnologies(PlayerTechnology.values());
    command.setPlayers(players.toArray(new Player[players.size()]));
    command.setAdmin(user.isAdminRole());
    model.addAttribute("command", command);
}
Also used : PlayerSettingsCommand(org.libresonic.player.command.PlayerSettingsCommand) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Aggregations

PlayerSettingsCommand (org.libresonic.player.command.PlayerSettingsCommand)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1