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