From b16b544a3982da609564491ac207e74c0e121c25 Mon Sep 17 00:00:00 2001 From: undisclosed Date: Sat, 31 Dec 2022 16:09:31 +0000 Subject: [PATCH] VLC Basiskommandos play, pause, stop eingebaut --- src/de/uhilger/calypso/handler/OMXPlayer.java | 84 +++++++++++++---------------------------- 1 files changed, 27 insertions(+), 57 deletions(-) diff --git a/src/de/uhilger/calypso/handler/OMXPlayer.java b/src/de/uhilger/calypso/handler/OMXPlayer.java index 2321e70..f012ad9 100644 --- a/src/de/uhilger/calypso/handler/OMXPlayer.java +++ b/src/de/uhilger/calypso/handler/OMXPlayer.java @@ -18,6 +18,7 @@ package de.uhilger.calypso.handler; +import com.sun.net.httpserver.HttpExchange; import de.uhilger.calypso.App; import de.uhilger.calypso.MeldeThread; import de.uhilger.calypso.ProzessLauscher; @@ -27,11 +28,10 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,17 +45,18 @@ * * @author ulrich */ -public class OMXPlayer implements Player , ProzessLauscher { +public class OMXPlayer extends BasePlayer implements Player , ProzessLauscher { private static final Logger logger = Logger.getLogger(OMXPlayer.class.getName()); public static final String NAME = "omxplayer"; public static final String BLANK = " "; + public static final String CMD_TOGGLE_INFO = "z"; public static final String CMD_DEC_SPEED = "1"; public static final String CMD_DEC_VOL = "-"; public static final String CMD_INC_SPEED = "2"; - public static final String CMD_INC_VOL = "+"; + public static final String CMD_INC_VOL = "="; // oder "+"; public static final String CMD_NEXT_AUDIO = "k"; public static final String CMD_NEXT_CHAPTER = "o"; public static final String CMD_NEXT_SUB = "m"; @@ -65,8 +66,6 @@ public static final String CMD_PREV_SUB = "n"; public static final String CMD_STOP = "q"; public static final String CMD_TOGGLE_SUB = "s"; - public static final String F_PING = "ping"; - public static final String F_PLAY = "play"; public static final String F_PLAY_ON = "playon"; public static final String F_SEEK = "seek"; public static final String OPT_HDMI_AUDIO = "-o%20hdmi"; @@ -116,6 +115,23 @@ } return antwort; } + + @Override + public StringBuilder buildParams(HttpExchange t, Map map) { + StringBuilder params = new StringBuilder(); + params.append("-o "); + params.append(getParam(map, "o")); + params.append(" --threshold "); + params.append(getParam(map, "th")); + params.append(" --timeout "); + params.append(getParam(map, "ti")); + String log = getParam(map, "log"); + if (log != null && log.equalsIgnoreCase("true")) { + params.append(" --genlog"); + } + return params; + } + /** * Einen eventuell laufenden Abspielprozess beenden und den @@ -130,6 +146,7 @@ * * @return die Antwort des Servers */ + /* @Override public String tilgen() { String antwort; // = null; @@ -148,59 +165,11 @@ } return antwort; } - - - /** - * 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(); - if(k.equals(CMD_STOP)) { - out.close(); - - /* - fuer den Fall, dass ein Stopp-Signal den Player nicht erreicht - oder dort nicht funktioniert, gibt es keine Moeglichkeit festzustellen, - dass der Player noch spielt. Damit in einem solchen Fall der Zeiger - auf den Abspielprozess nicht verloren geht, wird der Zeiger nicht - auf null gesetzt. - */ - - //App.setPlayerProcess(null); - //player_process.destroy(); - //player_process = null; - //t.setAttribute(App.PI_PLAYER, null); - //servletContext.removeAttribute(PI_PLAYER); - } - antwort = "Kommando '" + k + "' ausgefuehrt."; - } - } - catch(IOException ex) { - antwort = "Fehler: " + ex.getMessage(); - } - return antwort; - } + */ /* ------ Implementierung ProzessLauscher ----------------- */ + /* @Override public void prozessBeendet(String meldeUrlStr) { try { @@ -219,9 +188,10 @@ auf null gesetzt. */ //App.setPlayerProcess(null); + /* } catch(IOException ex) { logger.log(Level.INFO, ex.getMessage(), ex); } } - + */ } -- Gitblit v1.9.3