commit | author | age
|
7a79ba
|
1 |
package de.uhilger.calypso.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import de.uhilger.calypso.App; |
|
5 |
import de.uhilger.calypso.MeldeThread; |
|
6 |
import java.io.IOException; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.logging.Level; |
|
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author Ulrich Hilger |
|
14 |
*/ |
|
15 |
public class MPlayer extends BasePlayer { |
|
16 |
|
|
17 |
private static final Logger logger = Logger.getLogger(MPlayer.class.getName()); |
|
18 |
|
|
19 |
public static final String CMD_STOP = "q"; |
|
20 |
public static final String CMD_PAUSE_RESUME = "p"; |
|
21 |
|
|
22 |
@Override |
|
23 |
public String abspielen(String urlStr, String parameter, String meldeUrlStr, String token) { |
|
24 |
String antwort;// = null; |
|
25 |
try { |
|
26 |
//Object o = t.getAttribute(App.PI_PLAYER); |
|
27 |
Process o = App.getPlayerProcess(); |
|
28 |
if(o != null) { |
|
29 |
tilgen(); |
|
30 |
} |
|
31 |
StringBuilder kommando = new StringBuilder("mplayer -cache 2048 -cache-min 80 -really-quiet -framedrop "); |
|
32 |
/* |
|
33 |
if(parameter != null) { |
|
34 |
kommando.append(parameter); |
|
35 |
kommando.append(BLANK); |
|
36 |
} |
|
37 |
*/ |
|
38 |
if(urlStr.startsWith("http")) { |
|
39 |
kommando.append(urlStr.replace(" ", "%20")); |
|
40 |
//kommando.append("?t="); |
|
41 |
//kommando.append(token); |
|
42 |
} else { |
|
43 |
/* |
|
44 |
//url z.B.: Filme/H/HEAT_D2.m4v |
|
45 |
|
|
46 |
hier muss noch der Pfad hinzugefuegt werden, unter |
|
47 |
dem auf dem raspi die Datenquelle via NFS eingebunden ist, |
|
48 |
z.B. /media/mc/ |
|
49 |
dieser Teil des Pfades muss in pirc als Init-Parameter oder |
|
50 |
etwas aehnliches hinterlegt sein, weil es lokal zum jeweils |
|
51 |
verwendeten raspi gehoert |
|
52 |
|
|
53 |
*/ |
|
54 |
|
|
55 |
String pfad = App.getInitParameter("nfs-prefix"); |
|
56 |
kommando.append(pfad); |
|
57 |
|
|
58 |
kommando.append(urlStr); |
|
59 |
} |
|
60 |
//kommando.append(" vlc://quit"); |
|
61 |
//kommando.append(" >>/dev/null 2>&1"); |
|
62 |
logger.log(Level.FINE, "kommando: {0}", kommando.toString()); |
|
63 |
Process player_process = Runtime.getRuntime().exec(kommando.toString()); |
|
64 |
if(meldeUrlStr != null) { |
|
65 |
MeldeThread mt = new MeldeThread(); |
|
66 |
mt.setProcess(player_process); |
|
67 |
mt.lauscherHinzufuegen(this); |
|
68 |
mt.setMeldeUrl(meldeUrlStr); |
|
69 |
mt.start(); |
|
70 |
} |
|
71 |
//servletContext.setAttribute(App.PI_PLAYER, player_process); |
|
72 |
//t.setAttribute(App.PI_PLAYER, player_process); |
|
73 |
App.setPlayerProcess(player_process); |
|
74 |
//Runtime.getRuntime().exec("killall dbus-daemon"); |
|
75 |
antwort = "Abspielen gestartet, url: " + urlStr; |
|
76 |
} |
|
77 |
catch(IOException ex) { |
|
78 |
antwort = "Fehler: " + ex.getMessage(); |
|
79 |
} |
|
80 |
return antwort; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public StringBuilder buildParams(HttpExchange t, Map m) { |
|
85 |
return new StringBuilder(); |
|
86 |
} |
|
87 |
|
|
88 |
} |