| | |
| | | |
| | | 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; |
| | | |
| | |
| | | public abstract class BasePlayer implements Player { |
| | | |
| | | 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 |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |