我有带有 Raspbian OS 的 RaspberryPi2(1GB RAM 版本)。我需要执行 Omxplayer 来播放视频。如果我执行新进程,Omxplayer 在后台。我需要 Omxplayer 始终处于领先地位。怎么做?Omxplayer 没有像 mplayer (-ontop) 那样切换到顶部。
我发现(https://askubuntu.com/questions/7377/how-to-start-an-app-with-always-on-top-set)wmctrl。我尝试运行执行 omxplayer 的 java,然后执行:
ProcessBuilder pb2 = new ProcessBuilder("bash", "-c", "wmctrl -a omxplayer");
Process p2 = pb2.start(); // Start the process.
但不起作用,可能是因为 JavaFX 使用帧缓冲区,而不是 X11。资料来源:为什么我的 JavaFx 应用程序在我的 RaspberryPi 上运行时没有框架?
我觉得在 RaspberryPi 上全屏运行 Omxplayer 是不可能的。
将 omxplayer 作为新进程运行的代码:
public class OmxPlayer {
private int xPosition;
private int yPosition;
private int width;
private int height;
/** Constructor.
*
* */
OmxPlayer (int xPosition, int yPosition, int width, int height) {
this.xPosition = xPosition;
this.yPosition = yPosition;
this.width = width;
this.height = height;
}
public void play(String url){
try {
ProcessBuilder pb = new ProcessBuilder("bash", "-c", "omxplayer -r -o hdmi "+url);
Process p = pb.start(); // Start the process.
Log.write("I am playing file: "+url, Log.ENABLE_STDOUT);
//p.waitFor(); // Wait for the process to finish.
Log.write("File was played.", Log.ENABLE_STDOUT);
} catch (Exception e) {
StringWriter err = new StringWriter();
e.printStackTrace(new PrintWriter(err));
Log.write(err.toString(), Log.ENABLE_STDOUT);
}
}
}
谢谢你。