commit | author | age
|
ac496f
|
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 |
/** |
aaed2d
|
10 |
* dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 |
U |
11 |
* org.mpris.MediaPlayer2.Player.Seek int64:-5000000 |
|
12 |
* |
ac496f
|
13 |
* @author Ulrich Hilger |
U |
14 |
*/ |
|
15 |
public class VLCSeekHandler extends CmdHandler { |
aaed2d
|
16 |
|
ac496f
|
17 |
private static final Logger logger = Logger.getLogger(VLCSeekHandler.class.getName()); |
aaed2d
|
18 |
|
ac496f
|
19 |
public VLCSeekHandler(String cmd) { |
U |
20 |
super(cmd); |
|
21 |
} |
aaed2d
|
22 |
|
ac496f
|
23 |
@Override |
U |
24 |
protected String process(HttpExchange t, String params) { |
aaed2d
|
25 |
String antwort;// = null; |
ac496f
|
26 |
try { |
U |
27 |
StringBuilder kommando = new StringBuilder(); |
|
28 |
kommando.append(VLCPlayer.DBUS_PREFIX); |
|
29 |
kommando.append(cmd); |
|
30 |
kommando.append(params); |
|
31 |
logger.log(Level.FINE, "kommando: {0}", kommando.toString()); |
|
32 |
Process player_process = Runtime.getRuntime().exec(kommando.toString()); |
|
33 |
antwort = "Kommando ausgefuehrt: " + kommando; |
|
34 |
} catch (IOException ex) { |
|
35 |
antwort = "Fehler: " + ex.getMessage(); |
|
36 |
} |
|
37 |
return antwort; |
|
38 |
} |
aaed2d
|
39 |
|
ac496f
|
40 |
@Override |
U |
41 |
protected StringBuilder buildParams(HttpExchange t) { |
|
42 |
Player player = App.getPlayer(); |
|
43 |
StringBuilder params = super.buildParams(t); |
aaed2d
|
44 |
|
U |
45 |
if (player instanceof VLCPlayer) { |
ac496f
|
46 |
String pos = player.getParam(map, "pos"); |
aaed2d
|
47 |
if (!pos.isEmpty()) { |
ac496f
|
48 |
params.append(" "); |
U |
49 |
params.append("int64:"); |
|
50 |
params.append(pos); |
|
51 |
params.append("000000"); // Mikrosekunden |
|
52 |
} |
|
53 |
} |
aaed2d
|
54 |
|
ac496f
|
55 |
logger.log(Level.FINER, "params: " + params.toString()); |
U |
56 |
return params; |
aaed2d
|
57 |
} |
ac496f
|
58 |
} |