From 0c8d27c8a1708d1c315aca89db47d48488fd44ca Mon Sep 17 00:00:00 2001 From: ulrich Date: Mon, 22 Mar 2021 07:53:34 +0000 Subject: [PATCH] Play/Stop in Arbeit --- src/de/uhilger/avdirektor/handler/OMXPlayer.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/de/uhilger/avdirektor/handler/OMXPlayer.java b/src/de/uhilger/avdirektor/handler/OMXPlayer.java index d8f1f00..dc0a797 100644 --- a/src/de/uhilger/avdirektor/handler/OMXPlayer.java +++ b/src/de/uhilger/avdirektor/handler/OMXPlayer.java @@ -16,6 +16,9 @@ import java.io.Writer; import java.net.HttpURLConnection; import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -27,6 +30,46 @@ private static final Logger logger = Logger.getLogger(OMXPlayer.class.getName()); + protected String getParam(Map map, String key) { + Object o = map.get(key); + if(o != null) { + return o.toString(); + } else { + return null; + } + } + + protected Map getQueryMap(HttpExchange t) { + HashMap map = new HashMap(); + String query = t.getRequestURI().getQuery(); + if(query != null && query.length() > 0) { + String qParts[] = query.split("&"); + for(String qPart : qParts) { + //logger.info("qPart: " + qPart); + String pParts[] = qPart.split("="); + map.put(pParts[0], pParts[1]); + } + } + return map; + } + + protected String getResponseString(Map map, String cmd, String antwort) { + Set keys = map.keySet(); + StringBuilder buf = new StringBuilder(); + buf.append("play"); + buf.append(System.lineSeparator()); + keys.forEach((Object key) -> { + buf.append("key: "); + buf.append(key); + buf.append(System.lineSeparator()); + buf.append("value: "); + buf.append(map.get(key)); + buf.append(System.lineSeparator()); + //logger.log(Level.FINE, "key {0} value {1}", new Object[]{key, map.get(key)}); + }); + buf.append(antwort); + return buf.toString(); + } /** * Einen Prozess zum Abspielen mit dem omxplayer starten @@ -104,6 +147,7 @@ mt.start(); } //servletContext.setAttribute(App.PI_PLAYER, player_process); + t.setAttribute(App.PI_PLAYER, player_process); //Runtime.getRuntime().exec("killall dbus-daemon"); antwort = "Abspielen gestartet, url: " + urlStr; } -- Gitblit v1.9.3