commit | author | age
|
ac496f
|
1 |
/* |
U |
2 |
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
|
3 |
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
|
4 |
*/ |
|
5 |
package de.uhilger.calypso.handler; |
|
6 |
|
|
7 |
import com.sun.net.httpserver.HttpExchange; |
|
8 |
import de.uhilger.calypso.App; |
|
9 |
import java.io.IOException; |
|
10 |
import java.util.logging.Level; |
|
11 |
import java.util.logging.Logger; |
|
12 |
|
|
13 |
/** |
|
14 |
* dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:-5000000 |
|
15 |
* |
|
16 |
* @author Ulrich Hilger |
|
17 |
*/ |
|
18 |
public class VLCSeekHandler extends CmdHandler { |
|
19 |
|
|
20 |
private static final Logger logger = Logger.getLogger(VLCSeekHandler.class.getName()); |
|
21 |
|
|
22 |
public VLCSeekHandler(String cmd) { |
|
23 |
super(cmd); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected String process(HttpExchange t, String params) { |
|
28 |
String antwort;// = null; |
|
29 |
try { |
|
30 |
StringBuilder kommando = new StringBuilder(); |
|
31 |
kommando.append(VLCPlayer.DBUS_PREFIX); |
|
32 |
kommando.append(cmd); |
|
33 |
kommando.append(params); |
|
34 |
logger.log(Level.FINE, "kommando: {0}", kommando.toString()); |
|
35 |
Process player_process = Runtime.getRuntime().exec(kommando.toString()); |
|
36 |
antwort = "Kommando ausgefuehrt: " + kommando; |
|
37 |
} catch (IOException ex) { |
|
38 |
antwort = "Fehler: " + ex.getMessage(); |
|
39 |
} |
|
40 |
return antwort; |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected StringBuilder buildParams(HttpExchange t) { |
|
45 |
Player player = App.getPlayer(); |
|
46 |
StringBuilder params = super.buildParams(t); |
|
47 |
|
|
48 |
if(player instanceof VLCPlayer) { |
|
49 |
String pos = player.getParam(map, "pos"); |
|
50 |
if(!pos.isEmpty()) { |
|
51 |
params.append(" "); |
|
52 |
params.append("int64:"); |
|
53 |
params.append(pos); |
|
54 |
params.append("000000"); // Mikrosekunden |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
logger.log(Level.FINER, "params: " + params.toString()); |
|
59 |
return params; |
|
60 |
} |
|
61 |
} |