Wed Mar 20, 2013 11:40 am
He intentado llamar al proceso omxplayer desde Java, pero se me queda bloqueado sin que el video se reproduzca.
El código ejecutado es´:
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class execom {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//lectura del visualitzador
String vis = "/usr/bin/omxplayer.bin";
//Lectura video
String vid = "video1.mp4";
try
{
String osName = System.getProperty("os.name" );
String[] cmd = new String[7];
cmd[0]="/bin/bash";
cmd[1]="exec";
cmd[2]="-c";
cmd[3]=vis;
cmd[4]=vid;
cmd[5]=">/dev/null";
cmd[6]="2>/dev/null";
Runtime rt = Runtime.getRuntime();
System.out.println("Sistema OPeratiu: "+osName);
System.out.println("Executant.. " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]+" "+cmd[3]+" "+cmd[4]);
Process proc = rt.exec(cmd);
System.out.println("rt.exec realitzat de: "+cmd);
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
System.out.println("Iniciem el waitFor()...");
int exitVal = proc.waitFor();
System.out.println("ExitValue: " + exitVal);
} catch (Throwable t)
{
t.printStackTrace();
}
}
}