commit | author | age
|
8e2038
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.OutputStream; |
e448af
|
7 |
import java.util.Map; |
8e2038
|
8 |
import java.util.logging.Level; |
U |
9 |
import java.util.logging.Logger; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
* @author ulrich |
|
14 |
*/ |
63b711
|
15 |
public class PlayHandler extends CmdHandler { |
8e2038
|
16 |
|
U |
17 |
private static final Logger logger = Logger.getLogger(PlayHandler.class.getName()); |
63b711
|
18 |
|
U |
19 |
public PlayHandler(String cmd) { |
|
20 |
super(cmd); |
|
21 |
} |
8e2038
|
22 |
|
a7f0a1
|
23 |
/* |
cc2a32
|
24 |
rpi4-az:9090/avd/play?titel=/Filme/S/sound_city.m4v&th=60&ti=60&o=local |
a7f0a1
|
25 |
|
U |
26 |
OMXPlayer.abspielenMitParameternUndRueckmeldung( |
|
27 |
String urlStr, String parameter, String meldeUrlStr, String token) |
|
28 |
|
cc2a32
|
29 |
Parameter des Aufrufs play als query (th threshold, ti timeout) |
a7f0a1
|
30 |
|
U |
31 |
?titel=/Filme/S/sound_city.m4v |
|
32 |
&ti=60 |
|
33 |
&th=60 |
|
34 |
&o=local|hdmi|both |
|
35 |
&r=http://uhilger.de/mc/api/usw |
|
36 |
|
|
37 |
r muss ganz wegbleiben, wenn keine Rueckmeldung gewuescht ist |
|
38 |
|
|
39 |
*/ |
63b711
|
40 |
/* |
8e2038
|
41 |
@Override |
U |
42 |
public void handle(HttpExchange t) throws IOException { |
0c8d27
|
43 |
logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); |
8e2038
|
44 |
|
63b711
|
45 |
StringBuilder params = buildParams(t); |
U |
46 |
|
|
47 |
String antwort = abspielenMitParameternUndRueckmeldung( |
|
48 |
getParam(map, "titel"), params.toString(), getParam(map, "r"), "1"); |
|
49 |
|
|
50 |
sendResponse(t, "play", antwort); |
|
51 |
} |
|
52 |
*/ |
|
53 |
|
|
54 |
@Override |
|
55 |
protected String process(HttpExchange t, String params) { |
|
56 |
String antwort = abspielenMitParameternUndRueckmeldung( |
|
57 |
getParam(map, "titel"), params, getParam(map, "r"), "1"); |
|
58 |
logger.log(Level.FINE, antwort); |
|
59 |
return antwort; |
|
60 |
} |
|
61 |
|
|
62 |
protected StringBuilder buildParams(HttpExchange t) { |
|
63 |
StringBuilder params = super.buildParams(t); |
a7f0a1
|
64 |
params.append("-o "); |
U |
65 |
params.append(getParam(map, "o")); |
|
66 |
params.append(" --threshold "); |
|
67 |
params.append(getParam(map, "th")); |
|
68 |
params.append(" --timeout "); |
|
69 |
params.append(getParam(map, "ti")); |
63b711
|
70 |
return params; |
8e2038
|
71 |
} |
cc2a32
|
72 |
|
8e2038
|
73 |
} |