From 7a79ba8b70e8541b6d4413a46061b2c03ecddc9b Mon Sep 17 00:00:00 2001
From: undisclosed
Date: Tue, 03 Jan 2023 10:47:17 +0000
Subject: [PATCH] Baustelle: Versuche mit unterschiedlichen Playern
---
src/de/uhilger/calypso/handler/BasePlayer.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/src/de/uhilger/calypso/handler/BasePlayer.java b/src/de/uhilger/calypso/handler/BasePlayer.java
index 28a052d..19576a4 100644
--- a/src/de/uhilger/calypso/handler/BasePlayer.java
+++ b/src/de/uhilger/calypso/handler/BasePlayer.java
@@ -2,9 +2,14 @@
import de.uhilger.calypso.App;
import static de.uhilger.calypso.handler.OMXPlayer.CMD_STOP;
+import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -16,6 +21,9 @@
private static final Logger logger = Logger.getLogger(BasePlayer.class.getName());
+ public static final String F_PLAY = "play";
+ public static final String F_PING = "ping";
+
@Override
public void prozessBeendet(String meldeUrlStr) {
@@ -62,5 +70,46 @@
}
return antwort;
}
-
+
+ public String getParam(Map map, String key) {
+ Object o = map.get(key);
+ if(o != null) {
+ return o.toString();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Dem laufenden Abspielprozess ein Kommando uebermitteln
+ * @param k das Kommando laut
+ * <a href="https://github.com/huceke/omxplayer/blob/master/README.md" target="_blank">Liste der Kommandos</a>
+ * @return die Antwort des Servers
+ */
+ @Override
+ public String kommando(String k) {
+ String antwort; // = null;
+ try {
+ //Object o = t.getAttribute(App.PI_PLAYER);
+ Process o = App.getPlayerProcess();
+ if(o == null) {
+ //App.setPlayerProcess(null);
+ //servletContext.removeAttribute(PI_PLAYER);
+ //t.setAttribute(App.PI_PLAYER, null);
+ antwort = "Es wird nichts abgespielt dem ein Kommando gesendet werden kann.";
+ } else {
+ Process player_process = o;
+ OutputStream os = player_process.getOutputStream();
+ Writer out = new BufferedWriter(new OutputStreamWriter(os));
+ out.write(k);
+ out.flush();
+ antwort = "Kommando '" + k + "' ausgefuehrt.";
+ }
+ }
+ catch(IOException ex) {
+ antwort = "Fehler: " + ex.getMessage();
+ }
+ return antwort;
+ }
+
}
--
Gitblit v1.9.3