package de.uhilger.calypso.handler; import com.sun.net.httpserver.HttpExchange; import de.uhilger.calypso.App; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; /** * http://server:9090/calypso/seek?pos=30 (30 Sekunden vor) oder pos=-30 (zurueck) * * echo '{"command": ["seek", '30']}' | socat - /tmp/mpvsocket * echo '{"command": ["seek", '-30']}' | socat - /tmp/mpvsocket * * in einem Shell Skript * echo '{"command": ["seek", '$1']}' | socat - /tmp/mpvsocket * * * @author Ulrich Hilger */ public class MPVSeekHandler extends CmdHandler { private static final Logger logger = Logger.getLogger(MPVSeekHandler.class.getName()); public MPVSeekHandler(String cmd) { super(cmd); } @Override protected String process(HttpExchange t, String params) { String antwort;// = null; try { StringBuilder kommando = new StringBuilder(); //kommando.append(VLCPlayer.DBUS_PREFIX); kommando.append(cmd); kommando.append(params); logger.log(Level.FINE, "kommando: {0}", kommando.toString()); Process player_process = Runtime.getRuntime().exec(kommando.toString()); antwort = "Kommando ausgefuehrt: " + kommando; } catch (IOException ex) { antwort = "Fehler: " + ex.getMessage(); } return antwort; } @Override protected StringBuilder buildParams(HttpExchange t) { Player player = App.getPlayer(); StringBuilder params = super.buildParams(t); if (player instanceof MPVPlayer) { String pos = player.getParam(map, "pos"); if (!pos.isEmpty()) { params.append(" "); params.append(pos); } } logger.log(Level.FINER, "params: " + params.toString()); return params; } }