From ac496f2285d0f79b0124528edd636a732739829a Mon Sep 17 00:00:00 2001 From: undisclosed Date: Sun, 01 Jan 2023 17:29:03 +0000 Subject: [PATCH] Seek fuer VLC eingebaut --- src/de/uhilger/calypso/Server.java | 61 +++++++++++++++++++++--------- 1 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/de/uhilger/calypso/Server.java b/src/de/uhilger/calypso/Server.java index d1064a1..cab92a6 100644 --- a/src/de/uhilger/calypso/Server.java +++ b/src/de/uhilger/calypso/Server.java @@ -14,12 +14,13 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. -*/ - + */ package de.uhilger.calypso; import com.sun.net.httpserver.HttpServer; +import de.uhilger.calypso.handler.BasePlayer; import de.uhilger.calypso.handler.CmdHandler; +import de.uhilger.calypso.handler.DBusHandler; import de.uhilger.calypso.handler.FileHandler; import de.uhilger.calypso.handler.LogHandler; import de.uhilger.calypso.handler.OMXPlayer; @@ -28,45 +29,69 @@ import de.uhilger.calypso.handler.PlayOnHandler; import de.uhilger.calypso.handler.SeekHandler; 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.IOException; import java.util.logging.Logger; import java.net.InetSocketAddress; import java.util.concurrent.Executors; +import java.util.logging.Level; /** * * @author ulrich */ public class Server { - + private static final Logger logger = Logger.getLogger(Server.class.getName()); private int port; - + + private String contextName; + public Server(int port) { this.port = port; } - + public void setPort(int port) { this.port = port; } - - public void start() throws IOException { - logger.info("Server starting on port " + port); + + /** + * + * @param contextName e.g. '/calypso' or '/cal' + */ + public void setContextName(String contextName) { + this.contextName = contextName; + } + + public void start(String playerType) throws IOException { + logger.log(Level.INFO, "Server starting on port {0}", port); HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); - server.createContext("/avd/play", new PlayHandler(OMXPlayer.F_PLAY)); - server.createContext("/avd/seek", new SeekHandler(OMXPlayer.F_SEEK)); - server.createContext("/avd/stop", new CmdHandler(OMXPlayer.CMD_STOP)); - server.createContext("/avd/pause", new CmdHandler(OMXPlayer.CMD_PAUSE_RESUME)); - server.createContext("/avd/ping", new PingHandler(OMXPlayer.F_PING)); - server.createContext("/avd/server/stop", new StopServerHandler()); - server.createContext("/avd/log", new LogHandler()); - server.createContext("/avd/playon", new PlayOnHandler(OMXPlayer.F_PLAY_ON)); - server.createContext("/avd/ui", new FileHandler(App.getInitParameter(App.IP_WWW_DATA))); + server.createContext(contextName + "/play", new PlayHandler(BasePlayer.F_PLAY)); + if (playerType.equals(App.OMX_PLAYER)) { + 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)); + server.createContext(contextName + "/vol-inc", new CmdHandler(OMXPlayer.CMD_INC_VOL)); + server.createContext(contextName + "/vol-dec", new CmdHandler(OMXPlayer.CMD_DEC_VOL)); + server.createContext(contextName + "/info", new CmdHandler(OMXPlayer.CMD_TOGGLE_INFO)); + 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 + "/pause", new DBusHandler(VLCPlayer.CMD_PAUSE_RESUME)); + //server.createContext(contextName + "/seek", new DBusHandler(VLCPlayer.CMD_SEEK)); + server.createContext(contextName + "/seek", new VLCSeekHandler(VLCPlayer.CMD_SEEK)); + server.createContext(contextName + "/stop", new VLCKillHandler()); + } + server.createContext(contextName + "/ui", new FileHandler(App.getInitParameter(App.IP_WWW_DATA))); + server.createContext(contextName + "/ping", new PingHandler(BasePlayer.F_PING)); + server.createContext(contextName + "/server/stop", new StopServerHandler()); //server.setExecutor(null); // creates a default executor server.setExecutor(Executors.newFixedThreadPool(20)); server.start(); - } + } } -- Gitblit v1.9.3