commit | author | age
|
098eef
|
1 |
package de.uhilger.calypso.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import de.uhilger.calypso.App; |
|
5 |
import java.io.IOException; |
|
6 |
import java.util.logging.Level; |
|
7 |
import java.util.logging.Logger; |
|
8 |
|
|
9 |
/** |
|
10 |
* http://server:9090/calypso/seek?pos=30 (30 Sekunden vor) oder pos=-30 (zurueck) |
|
11 |
* |
|
12 |
* echo '{"command": ["seek", '30']}' | socat - /tmp/mpvsocket |
|
13 |
* echo '{"command": ["seek", '-30']}' | socat - /tmp/mpvsocket |
|
14 |
* |
|
15 |
* in einem Shell Skript |
|
16 |
* echo '{"command": ["seek", '$1']}' | socat - /tmp/mpvsocket |
|
17 |
* |
|
18 |
* |
|
19 |
* @author Ulrich Hilger |
|
20 |
*/ |
|
21 |
public class MPVSeekHandler extends CmdHandler { |
|
22 |
|
|
23 |
private static final Logger logger = Logger.getLogger(MPVSeekHandler.class.getName()); |
|
24 |
|
|
25 |
public MPVSeekHandler(String cmd) { |
|
26 |
super(cmd); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
protected String process(HttpExchange t, String params) { |
|
31 |
String antwort;// = null; |
|
32 |
try { |
|
33 |
StringBuilder kommando = new StringBuilder(); |
|
34 |
//kommando.append(VLCPlayer.DBUS_PREFIX); |
|
35 |
kommando.append(cmd); |
|
36 |
kommando.append(params); |
|
37 |
logger.log(Level.FINE, "kommando: {0}", kommando.toString()); |
|
38 |
Process player_process = Runtime.getRuntime().exec(kommando.toString()); |
|
39 |
antwort = "Kommando ausgefuehrt: " + kommando; |
|
40 |
} catch (IOException ex) { |
|
41 |
antwort = "Fehler: " + ex.getMessage(); |
|
42 |
} |
|
43 |
return antwort; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected StringBuilder buildParams(HttpExchange t) { |
|
48 |
Player player = App.getPlayer(); |
|
49 |
StringBuilder params = super.buildParams(t); |
|
50 |
|
|
51 |
if (player instanceof MPVPlayer) { |
|
52 |
String pos = player.getParam(map, "pos"); |
|
53 |
if (!pos.isEmpty()) { |
|
54 |
params.append(" "); |
|
55 |
params.append(pos); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
logger.log(Level.FINER, "params: " + params.toString()); |
|
60 |
return params; |
|
61 |
} |
|
62 |
} |