From 2f2aa7d344d41c6d4083149b1ea6b41e7fb1f683 Mon Sep 17 00:00:00 2001
From: undisclosed
Date: Sat, 07 Jan 2023 15:24:26 +0000
Subject: [PATCH] Baustelle: Calypso 'ins Reine' bauen

---
 src/de/uhilger/calypso/Server.java |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/de/uhilger/calypso/Server.java b/src/de/uhilger/calypso/Server.java
index df18287..9948ece 100644
--- a/src/de/uhilger/calypso/Server.java
+++ b/src/de/uhilger/calypso/Server.java
@@ -23,15 +23,23 @@
 import de.uhilger.calypso.handler.DBusHandler;
 import de.uhilger.calypso.handler.FileHandler;
 import de.uhilger.calypso.handler.LogHandler;
+import de.uhilger.calypso.handler.MPVKillHandler;
+import de.uhilger.calypso.handler.MPVPlayHandler;
+import de.uhilger.calypso.handler.MPVPlayer;
+import de.uhilger.calypso.handler.MPVSeekHandler;
+import de.uhilger.calypso.handler.MPlayHandler;
+import de.uhilger.calypso.handler.MPlayer;
 import de.uhilger.calypso.handler.OMXPlayer;
 import de.uhilger.calypso.handler.PingHandler;
 import de.uhilger.calypso.handler.PlayHandler;
 import de.uhilger.calypso.handler.PlayOnHandler;
 import de.uhilger.calypso.handler.SeekHandler;
+import de.uhilger.calypso.handler.SocketHandler;
 import de.uhilger.calypso.handler.StopServerHandler;
 import de.uhilger.calypso.handler.VLCKillHandler;
 import de.uhilger.calypso.handler.VLCPlayer;
 import de.uhilger.calypso.handler.VLCSeekHandler;
+import java.io.File;
 import java.io.IOException;
 import java.util.logging.Logger;
 import java.net.InetSocketAddress;
@@ -73,12 +81,18 @@
 
   private String contextName;
 
+  private String path;
+  
   public Server(int port) {
     this.port = port;
   }
 
   public void setPort(int port) {
     this.port = port;
+  }
+  
+  public void setPath(String path) {
+    this.path = path;
   }
 
   /**
@@ -93,8 +107,9 @@
     logger.log(Level.INFO, "Server starting on port {0}", port);
 
     HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
-    server.createContext(contextName + "/play", new PlayHandler(BasePlayer.F_PLAY));
+    
     if (playerType.equals(App.OMX_PLAYER)) {
+      server.createContext(contextName + "/play", new PlayHandler(BasePlayer.F_PLAY));
       server.createContext(contextName + "/seek", new SeekHandler(OMXPlayer.F_SEEK));
       server.createContext(contextName + "/stop", new CmdHandler(OMXPlayer.CMD_STOP));
       server.createContext(contextName + "/pause", new CmdHandler(OMXPlayer.CMD_PAUSE_RESUME));
@@ -104,10 +119,21 @@
       server.createContext(contextName + "/log", new LogHandler());
       server.createContext(contextName + "/playon", new PlayOnHandler(OMXPlayer.F_PLAY_ON));
     } else if (playerType.equals(App.VLC_PLAYER)) {
+      server.createContext(contextName + "/play", new PlayHandler(BasePlayer.F_PLAY));
       server.createContext(contextName + "/pause", new DBusHandler(VLCPlayer.CMD_PAUSE_RESUME));
+      //server.createContext(contextName + "/pause", new CmdHandler("pause"));
       //server.createContext(contextName + "/seek", new DBusHandler(VLCPlayer.CMD_SEEK));
       server.createContext(contextName + "/seek", new VLCSeekHandler(VLCPlayer.CMD_SEEK));
       server.createContext(contextName + "/stop", new VLCKillHandler());
+    } else if (playerType.equals(App.M_PLAYER)) {
+      server.createContext(contextName + "/play", new MPlayHandler());
+      server.createContext(contextName + "/pause", new CmdHandler(MPlayer.CMD_PAUSE_RESUME));
+      server.createContext(contextName + "/stop", new CmdHandler(MPlayer.CMD_STOP));
+    } else if (playerType.equals(App.MPV_PLAYER)) {
+      server.createContext(contextName + "/play", new MPVPlayHandler());
+      server.createContext(contextName + "/pause", new SocketHandler(path + MPVPlayer.CMD_PAUSE_RESUME));
+      server.createContext(contextName + "/seek", new MPVSeekHandler(path + MPVPlayer.CMD_SEEK));
+      server.createContext(contextName + "/stop", new MPVKillHandler());
     }
     server.createContext(contextName + "/ui", new FileHandler(App.getInitParameter(App.IP_WWW_DATA)));
     server.createContext(contextName + "/ping", new PingHandler(BasePlayer.F_PING));

--
Gitblit v1.9.3