/*
|
* 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 de.uhilger.calypso.App;
|
import de.uhilger.calypso.MeldeThread;
|
import static de.uhilger.calypso.handler.OMXPlayer.BLANK;
|
import java.io.IOException;
|
import java.util.logging.Level;
|
import java.util.logging.Logger;
|
|
/**
|
*
|
* @author ulrich
|
*/
|
public class VLCPlayer implements Player {
|
|
private static final Logger logger = Logger.getLogger(VLCPlayer.class.getName());
|
|
@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);
|
}
|
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;
|
}
|
|
@Override
|
public String kommando(String k) {
|
if(k.equalsIgnoreCase(OMXPlayer.CMD_STOP)) {
|
Process p = App.getPlayerProcess();
|
p.destroy();
|
App.setPlayerProcess(null);
|
}
|
String antwort = "Kommando '" + k + "' ausgefuehrt.";
|
return antwort;
|
}
|
|
@Override
|
public void prozessBeendet(String meldeUrlStr) {
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
}
|
|
@Override
|
public String tilgen() {
|
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
}
|
|
}
|