12

I wanted to play video file by doubling click on it by using omxplyaer. First time, I double-clicked on it, it asks me to choose an application to open the file. Since I cannot find omxplayer in installed application tab, I choose Custome Command Line tab and enter 'omxplyer' in command line to execute and again 'omxplayer' in Application name.

Now when I click on the video, it starts to play in omxplayer but hotkeys are no longer working. For example, I cannot quit video by hitting 'q' on keyboard and nothing of the hotkey works. This used to be working when I play a video file from lxterminal by typing 'omxplayer video.mp4'. But this is no longer the case.

If a video starts to play in full screen and since I no longer can quit omxplayer, I have to watch the video to end so that the player will quit. So my question is...

  1. How do I enable hotkey again when I play a video file with 'open with and then omxplayer' option?

  2. How do I delete the previous Command line to execute where I enter omxplayer so that when I click on a video file, it would ask me again to choose an application?

  • You can change the program to open a file with by right clicking on a file, "Open with.." and then choosing a program. Be sure to check the checkbox on the bottom "Set selected application as default action for this file type" if you want this, or don't if it's for single use. – Lonefish Feb 22 '16 at 7:44
  • Select the "Execute in terminal" option. The shortcuts don't work without the terminal. – Wally Aug 26 '16 at 22:34
6

From a terminal:

pid=$(pidof omxplayer)
kill $pid

If it still doesn't stop, kill -9 $pid.

You can also use killall omxplayer and killall -s 9 omxplayer, which should stop all running instances (if there can be more than one).

  • By the way, I got the following error when I enter it into the terminal after the video is finished playing. "kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]" – Zip Feb 26 '15 at 17:56
  • 2
    Make sure there is something actually in $pid (you can't kill something that doesn't exist) and that it is just a number: echo $pid. If there's more than just a number, your ps was wrong; it must be exactly ps -o pid= -C omxplayer. I've edited the script version to account for this. – goldilocks Feb 26 '15 at 18:01
  • Sorry noob here. I do not know how your answer is related to my question. Is the script supposed to kill the current running omxplayer instance? The player does quit after the video is finished playing though. I just want to quit the player when it is playing a video, like click 'x' button on windows instead of waiting it playing finished the entire video. – Zip Feb 26 '15 at 18:05
  • 1
    If you can't quit the omxplayer through the normal interface, then either you have to wait for it to finish or you kill it externally. The script is just an elaboration of that concept. The basic idea is you open another terminal while omxplayer is running and kill it. If you can't do that (because omxplayer grabs the framebuffer -- I've never tried it from within X), switch to a different VT (virtual terminal -- there are at least 6) via ctrl-alt F[1-6] (just try the F-keys in order until you get a login prompt). – goldilocks Feb 26 '15 at 20:29
  • BTW: The whole problem of the normal hotkeys not working might be because LXDE is grabbing them, you should be able to configure LXDE/the LXDE terminal to not use overlapping hotkeys. – goldilocks Feb 26 '15 at 20:30
2

I just use the Alt+F4 to end the video.

1

While the other answers provide some inventive shell magic to kill a process running a specific command, there are actually two commands to do exactly this, and they are called pkill and killall. From the man pages:

pgrep,  pkill  -  look  up  or signal processes based on name and other
                  attributes

killall - kill processes by name

So

pkill omxplayer
killall omxplayer

should both do the trick.

Now, one could wonder why there are two commands to do the same thing. The reasons are mainly historical, dating back from a time when different unicies differed a little bit more than they usually do today.

There are also differences in what options they accept. For a longer discussion about the differences of pkill and killall, please see https://unix.stackexchange.com/questions/91527/whats-the-difference-between-pkill-and-killall

1

If you use the "Open with" option from the GUI you have to select "Execute in terminal emulator" option.

lxterminal -e omxplayer %F also works if you are on lxde,

Looks like the the the 'q' button and other shortcuts don't work if the terminal is not open. I had to power off the Pi a lot of times until I figured this out.

-1

Use this command in a terminal to kill omxplayer:

ps -ef | grep omxplayer | grep -v grep | awk '{print $2}' | xargs kill -9
  • It is worth noting that if the path to omxplayer is in a different location, such as /usr/local/bin then this command won't work. A more sure method would be to ps -ef | grep omxplayer | grep -v grep | awk '{print $2}' | xargs kill -9 – Greenonline Apr 19 '16 at 8:33
  • you are right. i just copied from my terminal and pasted. thank you. – Rubayet Apr 19 '16 at 9:13
  • 1
    That's a neat implementation of pkill ;) – Bex Apr 19 '16 at 10:09
-2

hey just try to run omxplayer in gui by linking it with tbo player it works perfectly

  • 2
    Welcome to Raspberry Pi! Please take the tour and visit the helpcenter to see how things work here. How does this address the question? Please be more explaining to make that a helpful answer. – Ghanima Jul 18 '17 at 6:00

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.