commit | author | age
|
229976
|
1 |
package de.uhilger.calypso.handler; |
cfe367
|
2 |
|
b16b54
|
3 |
import com.sun.net.httpserver.HttpExchange; |
229976
|
4 |
import de.uhilger.calypso.App; |
U |
5 |
import de.uhilger.calypso.MeldeThread; |
cfe367
|
6 |
import java.io.IOException; |
b16b54
|
7 |
import java.util.Map; |
cfe367
|
8 |
import java.util.logging.Level; |
U |
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author ulrich |
|
14 |
*/ |
82594d
|
15 |
public class VLCPlayer extends BasePlayer implements Player { |
cfe367
|
16 |
|
U |
17 |
private static final Logger logger = Logger.getLogger(VLCPlayer.class.getName()); |
b16b54
|
18 |
|
U |
19 |
public static final String CMD_STOP = "s"; |
ac496f
|
20 |
public static final String DBUS_PREFIX = "dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player."; |
U |
21 |
public static final String CMD_PAUSE_RESUME = "PlayPause"; |
|
22 |
public static final String CMD_SEEK = "Seek"; |
aaed2d
|
23 |
public static final String CMD_VOLUME = "Volume"; |
cfe367
|
24 |
|
U |
25 |
@Override |
|
26 |
public String abspielen(String urlStr, String parameter, String meldeUrlStr, String token) { |
|
27 |
String antwort;// = null; |
|
28 |
try { |
|
29 |
//Object o = t.getAttribute(App.PI_PLAYER); |
|
30 |
Process o = App.getPlayerProcess(); |
|
31 |
if(o != null) { |
|
32 |
tilgen(); |
|
33 |
} |
599fad
|
34 |
StringBuilder kommando = new StringBuilder("vlc --fullscreen "); |
cfe367
|
35 |
/* |
U |
36 |
if(parameter != null) { |
|
37 |
kommando.append(parameter); |
|
38 |
kommando.append(BLANK); |
|
39 |
} |
|
40 |
*/ |
|
41 |
if(urlStr.startsWith("http")) { |
|
42 |
kommando.append(urlStr.replace(" ", "%20")); |
|
43 |
kommando.append("?t="); |
|
44 |
kommando.append(token); |
|
45 |
} else { |
|
46 |
/* |
|
47 |
//url z.B.: Filme/H/HEAT_D2.m4v |
|
48 |
|
|
49 |
hier muss noch der Pfad hinzugefuegt werden, unter |
|
50 |
dem auf dem raspi die Datenquelle via NFS eingebunden ist, |
|
51 |
z.B. /media/mc/ |
|
52 |
dieser Teil des Pfades muss in pirc als Init-Parameter oder |
|
53 |
etwas aehnliches hinterlegt sein, weil es lokal zum jeweils |
|
54 |
verwendeten raspi gehoert |
|
55 |
|
|
56 |
*/ |
|
57 |
|
|
58 |
String pfad = App.getInitParameter("nfs-prefix"); |
|
59 |
kommando.append(pfad); |
|
60 |
|
|
61 |
kommando.append(urlStr); |
|
62 |
} |
82594d
|
63 |
kommando.append(" vlc://quit"); |
cfe367
|
64 |
logger.log(Level.FINE, "kommando: {0}", kommando.toString()); |
U |
65 |
Process player_process = Runtime.getRuntime().exec(kommando.toString()); |
|
66 |
if(meldeUrlStr != null) { |
|
67 |
MeldeThread mt = new MeldeThread(); |
|
68 |
mt.setProcess(player_process); |
|
69 |
mt.lauscherHinzufuegen(this); |
|
70 |
mt.setMeldeUrl(meldeUrlStr); |
|
71 |
mt.start(); |
|
72 |
} |
|
73 |
//servletContext.setAttribute(App.PI_PLAYER, player_process); |
|
74 |
//t.setAttribute(App.PI_PLAYER, player_process); |
|
75 |
App.setPlayerProcess(player_process); |
|
76 |
//Runtime.getRuntime().exec("killall dbus-daemon"); |
|
77 |
antwort = "Abspielen gestartet, url: " + urlStr; |
|
78 |
} |
|
79 |
catch(IOException ex) { |
|
80 |
antwort = "Fehler: " + ex.getMessage(); |
|
81 |
} |
|
82 |
return antwort; |
|
83 |
} |
|
84 |
|
b16b54
|
85 |
|
U |
86 |
/* |
cfe367
|
87 |
public String kommando(String k) { |
b16b54
|
88 |
if(k.equalsIgnoreCase(VLCPlayer.CMD_STOP)) { |
cfe367
|
89 |
Process p = App.getPlayerProcess(); |
U |
90 |
p.destroy(); |
|
91 |
App.setPlayerProcess(null); |
|
92 |
} |
|
93 |
String antwort = "Kommando '" + k + "' ausgefuehrt."; |
|
94 |
return antwort; |
|
95 |
} |
b16b54
|
96 |
*/ |
U |
97 |
|
|
98 |
@Override |
|
99 |
public StringBuilder buildParams(HttpExchange t, Map m) { |
|
100 |
return new StringBuilder(); |
|
101 |
} |
cfe367
|
102 |
|
U |
103 |
|
|
104 |
} |