/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package de.uhilger.calypso.handler; import com.sun.net.httpserver.HttpExchange; import de.uhilger.calypso.App; import de.uhilger.calypso.MeldeThread; import java.io.IOException; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author ulrich */ public class VLCPlayer extends BasePlayer implements Player { private static final Logger logger = Logger.getLogger(VLCPlayer.class.getName()); public static final String CMD_STOP = "s"; public static final String CMD_PAUSE_RESUME = "dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"; @Override public String abspielen(String urlStr, String parameter, String meldeUrlStr, String token) { String antwort;// = null; try { //Object o = t.getAttribute(App.PI_PLAYER); Process o = App.getPlayerProcess(); if(o != null) { tilgen(); } StringBuilder kommando = new StringBuilder("vlc --fullscreen "); /* if(parameter != null) { kommando.append(parameter); kommando.append(BLANK); } */ if(urlStr.startsWith("http")) { kommando.append(urlStr.replace(" ", "%20")); kommando.append("?t="); kommando.append(token); } else { /* //url z.B.: Filme/H/HEAT_D2.m4v hier muss noch der Pfad hinzugefuegt werden, unter dem auf dem raspi die Datenquelle via NFS eingebunden ist, z.B. /media/mc/ dieser Teil des Pfades muss in pirc als Init-Parameter oder etwas aehnliches hinterlegt sein, weil es lokal zum jeweils verwendeten raspi gehoert */ String pfad = App.getInitParameter("nfs-prefix"); kommando.append(pfad); kommando.append(urlStr); } kommando.append(" vlc://quit"); logger.log(Level.FINE, "kommando: {0}", kommando.toString()); Process player_process = Runtime.getRuntime().exec(kommando.toString()); if(meldeUrlStr != null) { MeldeThread mt = new MeldeThread(); mt.setProcess(player_process); mt.lauscherHinzufuegen(this); mt.setMeldeUrl(meldeUrlStr); mt.start(); } //servletContext.setAttribute(App.PI_PLAYER, player_process); //t.setAttribute(App.PI_PLAYER, player_process); App.setPlayerProcess(player_process); //Runtime.getRuntime().exec("killall dbus-daemon"); antwort = "Abspielen gestartet, url: " + urlStr; } catch(IOException ex) { antwort = "Fehler: " + ex.getMessage(); } return antwort; } /* public String kommando(String k) { if(k.equalsIgnoreCase(VLCPlayer.CMD_STOP)) { Process p = App.getPlayerProcess(); p.destroy(); App.setPlayerProcess(null); } String antwort = "Kommando '" + k + "' ausgefuehrt."; return antwort; } */ @Override public StringBuilder buildParams(HttpExchange t, Map m) { return new StringBuilder(); } }