运行omxplayer"始终在最前面"来自java代码

时间:2015-07-23 12:51:41

标签: java raspbian always-on-top omxplayer

我有RaspberryPi2(1GB RAM版本)和Raspbian OS。我需要执行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使用framebuffer,而不是使用X11。资料来源:Why does my JavaFx application not have a frame when run on my 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);
        }
    }
}

谢谢。

0 个答案:

没有答案