private String getProgressCommand(PlexBindingConfig config, Command command) { PlexSession session = getSessionByMachineId(config.getMachineIdentifier()); String url = null; if (session != null) { int offset = 0; if (command.getClass().equals(PercentType.class)) { PercentType percent = (PercentType) command; offset = new BigDecimal(session.getDuration()) .multiply( percent .toBigDecimal() .divide(new BigDecimal("100"), new MathContext(5, RoundingMode.HALF_UP))) .intValue(); offset = Math.max(0, offset); offset = Math.min(session.getDuration(), offset); url = String.format("playback/seekTo?offset=%d", offset); } else if (command.getClass().equals(IncreaseDecreaseType.class)) { if (command.equals(IncreaseDecreaseType.DECREASE)) { url = PlexProperty.STEP_BACK.getName(); } else { url = PlexProperty.STEP_FORWARD.getName(); } } } return url; }
@ActionDoc(text = "sets the master volume of the host") public static void setMasterVolume(@ParamDoc(name = "percent") final PercentType percent) throws IOException { setMasterVolume(percent.toBigDecimal().floatValue() / 100f); }