0

I'm firing OMXplayer from a JavaFX app and I need to stop the video when a certain event occurs. Does anyone know how to do this?

This is the way I start OMX

Process Builder pb = new ProcessBuilder("bash", "-c", "omxplayer -o hdmi " + path);
Process process = pb.start();
1

I would start looking at the Process.getOutputStream() method (more details, see http://docs.oracle.com/javase/7/docs/api/java/lang/Process.html), and pass the usual OMXPlayer commands into that stream (like 'q' for quit). If that doesn't work, you might need to look at the way you invoke OMXPlayer from ProcessBuilder - you either need to work with pipes or need to find a way to directly invoke OMXPlayer instead of running it as an argument to bash.

You might want to look at https://stackoverflow.com/questions/26389648/how-to-open-and-close-omxplayer-python-raspberry-pi-while-playing-video to see how the Answer provided answers the same problem in Python - principle should be the same.

  • 1
    Thanks @Phil B. I used the Process.getOutputStream() method and it worked nicely!!! – codenoob Aug 31 '15 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.