/*
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
*/
|
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;
|
|
/**
|
* dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:-5000000
|
*
|
* @author Ulrich Hilger
|
*/
|
public class VLCSeekHandler extends CmdHandler {
|
|
private static final Logger logger = Logger.getLogger(VLCSeekHandler.class.getName());
|
|
public VLCSeekHandler(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 VLCPlayer) {
|
String pos = player.getParam(map, "pos");
|
if(!pos.isEmpty()) {
|
params.append(" ");
|
params.append("int64:");
|
params.append(pos);
|
params.append("000000"); // Mikrosekunden
|
}
|
}
|
|
logger.log(Level.FINER, "params: " + params.toString());
|
return params;
|
}
|
}
|