| | |
| | | * |
| | | * HTTP POST /mz/api/strg/abspieler/play/titel mit dem Titel im Body |
| | | * HTTP POST /mz/api/strg/abspieler/play/stream mit dem Livestream im Body (nur Name gefuellt) |
| | | * |
| | | * HTTP POST /mz/api/strg/abspieler/weiter/titel mit dem Titel im Body |
| | | * |
| | | * HTTP GET /mz/api/strg/abspieler/pause |
| | | * HTTP GET /mz/api/strg/abspieler/stop |
| | | * HTTP GET /mz/api/strg/abspieler/weiter |
| | | * |
| | | * Faustregel: Anzahl Elemente eines URL plus 1 ist die Anzahl der Elemente des |
| | | * Ergebnisses von String.split. |
| | |
| | | |
| | | private static final Logger logger = Logger.getLogger(MediaSteuerung.class.getName()); |
| | | |
| | | public static final String PL_CMD_PLAY = "calypso/play"; |
| | | public static final String PL_CMD_PLAY = "play"; |
| | | public static final String PL_DEFAULT_PARAMS = "?titel="; |
| | | public static final String PL_PARAM_RUECK = "&r="; |
| | | public static final String PL_API_STRG = "/api/strg/"; |
| | | public static final String PL_API_STRG = "api/strg/"; |
| | | public static final String PL_CMD_ENDE = "ende"; |
| | | public static final String PL_CMD_STOP = "stop"; |
| | | public static final String PL_CMD_PAUSE = "pause"; |
| | | public static final String PL_CMD_PLAYON = "playon"; |
| | | public static final String PL_CMD_CALYPSO_STOP = "calypso/stop"; |
| | | public static final String PL_CMD_CALYPSO_PAUSE = "calypso/pause"; |
| | | public static final String PL_CMD_CALYPSO_PLAYON = "calypso/playon"; |
| | | public static final String PL_CMD_PLAYON = "weiter"; |
| | | public static final String PL_CMD_CALYPSO_STOP = "stop"; |
| | | public static final String PL_CMD_CALYPSO_PAUSE = "pause"; |
| | | public static final String PL_CMD_CALYPSO_PLAYON = "playon"; |
| | | public static final String DEFAULT_HOST = "http://localhost:9090"; |
| | | |
| | | private final Map spielt = new HashMap(); |
| | |
| | | response = kommandoSenden(fs, elems[4], PL_CMD_CALYPSO_STOP); |
| | | } else if(elems[5].equalsIgnoreCase(PL_CMD_PAUSE)) { |
| | | response = kommandoSenden(fs, elems[4], PL_CMD_CALYPSO_PAUSE); |
| | | } else if(elems[5].equalsIgnoreCase(PL_CMD_PLAYON)) { |
| | | response = kommandoSenden(fs, elems[4], PL_CMD_CALYPSO_PLAYON); |
| | | //} else if(elems[5].equalsIgnoreCase(PL_CMD_PLAYON)) { |
| | | // response = kommandoSenden(fs, elems[4], PL_CMD_CALYPSO_PLAYON); |
| | | } else { |
| | | response = meldung("Ungueltiges Kommando: " + elems[5], AbstractHandler.RTC_NOT_FOUND); |
| | | } |
| | |
| | | @Override |
| | | protected String post(HttpExchange e) { |
| | | String response; |
| | | String abspielerKmd = PL_CMD_PLAY; |
| | | String path = e.getRequestURI().toString(); |
| | | String[] elems = path.split(Server.SLASH); |
| | | logger.info(elems[5]); |
| | | if(elems[5].equalsIgnoreCase(PL_CMD_PLAYON)) { |
| | | abspielerKmd = PL_CMD_CALYPSO_PLAYON; |
| | | } else if(elems[5].equalsIgnoreCase(PL_CMD_PLAY)){ |
| | | abspielerKmd = PL_CMD_PLAY; |
| | | } |
| | | try { |
| | | return urlAbspielen(e); |
| | | return urlAbspielen(e, abspielerKmd); |
| | | } catch (IOException ex) { |
| | | logger.log(Level.SEVERE, null, ex); |
| | | return meldung(ex.getLocalizedMessage(), 404); |
| | |
| | | } |
| | | |
| | | // titel.katalogUrl + titel.pfad + titel.name |
| | | private String urlAbspielen(HttpExchange e) throws IOException { |
| | | private String urlAbspielen(HttpExchange e, String abspielerKmd) throws IOException { |
| | | String path = e.getRequestURI().toString(); |
| | | String[] elems = path.split(Server.SLASH); |
| | | FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); |
| | | if(elems[5].equalsIgnoreCase("titel")) { |
| | | if(elems[6].equalsIgnoreCase("titel")) { |
| | | String titelJson = bodyLesen(e); |
| | | Gson gson = new Gson(); |
| | | Object o = gson.fromJson(titelJson, fs.typeFromName(Titel.class.getSimpleName()).getType()); |
| | |
| | | if (entity instanceof Abspieler) { |
| | | Abspieler abspieler = (Abspieler) entity; |
| | | String server = getEinstellung(fs, App.getRs(App.RB_HOST), DEFAULT_HOST); |
| | | String signal = abspielKommando(fs, abspieler, server, titelUrl).toString(); |
| | | String signal = abspielKommando(fs, abspieler, server, titelUrl, abspielerKmd).toString(); |
| | | abspielerKommandoSenden(signal); |
| | | return signal + "gesendet."; |
| | | } else { |
| | |
| | | } else { |
| | | return meldung("Ungueltiger Titel.", 404); |
| | | } |
| | | } else if(elems[5].equalsIgnoreCase("stream")) { |
| | | } else if(elems[6].equalsIgnoreCase("stream")) { |
| | | String streamJson = bodyLesen(e); |
| | | Gson gson = new Gson(); |
| | | Object o = gson.fromJson(streamJson, fs.typeFromName(Livestream.class.getSimpleName()).getType()); |
| | |
| | | if (entity instanceof Abspieler) { |
| | | Abspieler abspieler = (Abspieler) entity; |
| | | String server = ""; |
| | | String signal = abspielKommando(fs, abspieler, server, stream.getUrl()).toString(); |
| | | String signal = abspielKommando(fs, abspieler, server, stream.getUrl(), PL_CMD_PLAY).toString(); |
| | | abspielerKommandoSenden(signal); |
| | | return signal + "gesendet."; |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private String kommandoSenden(Storage s, String aName, String kommando) { |
| | | Entity entity = s.read(FileStorage.ST_ABSPIELER, aName); |
| | | if (entity instanceof Abspieler) { |
| | |
| | | kmd.append(abspieler.getUrl()); |
| | | kmd.append(kommando); |
| | | String signal = kmd.toString(); |
| | | //String server = getEinstellung(s, App.getRs(App.RB_HOST), DEFAULT_HOST); |
| | | //String signal = abspielKommando(s, abspieler, server, stream.getUrl(), PL_CMD_PLAY).toString(); |
| | | abspielerKommandoSenden(signal); |
| | | return signal + " gesendet."; |
| | | } else { |
| | | return meldung("Abspielliste nicht gefunden.", AbstractHandler.RTC_NOT_FOUND); |
| | | } |
| | | } |
| | | |
| | | |
| | | private String ersterTitel(Storage s, String aName, String lName) { |
| | | String response; |
| | |
| | | kmd.append(server); |
| | | kmd.append(titelUrl); |
| | | */ |
| | | StringBuilder kmd = abspielKommando(s, abspieler, server, titelUrl); |
| | | StringBuilder kmd = abspielKommando(s, abspieler, server, titelUrl, PL_CMD_PLAY); |
| | | kmd.append(PL_PARAM_RUECK); |
| | | kmd.append(server); |
| | | kmd.append(PL_API_STRG); |
| | |
| | | return kmd.toString(); |
| | | } |
| | | |
| | | private StringBuilder abspielKommando(Storage s, Abspieler abspieler, String server, String titelUrl) { |
| | | private StringBuilder abspielKommando(Storage s, Abspieler abspieler, String server, String titelUrl, String abspielKmd) { |
| | | |
| | | // Kommando an den Abspieler zusammenbauen |
| | | StringBuilder kmd = new StringBuilder(); |
| | | kmd.append(abspieler.getUrl()); |
| | | kmd.append(PL_CMD_PLAY); |
| | | //kmd.append(PL_CMD_PLAY); |
| | | kmd.append(abspielKmd); |
| | | // Parameter fuer den Abspieler holen |
| | | kmd.append(getEinstellung(s, App.getRs(App.RB_PLAYERPARAMS), PL_DEFAULT_PARAMS)); |
| | | kmd.append(server); |