Friday, August 3, 2012

HOWTO: Launch OMXPlayer via a GUI

I'm going to be on an ARM kick for the next two weeks before my fall classes start up. In addition to porting Bodhi to the Pi one of my goals is also to replace my media PC with a Pi. Even though the processor in the Pi is fairly weak, it can decode HD video using it's GPU chip if you use the proper media player. This means that your old favorites like VLC and mPlayer will not work, so we must turn to a tool designed just for the Pi: OMXPlayer.

Now because OMXPlayer is still very new, it is still very basic. So basic in fact it's key bindings (for play/pause/stop/quit) only function if the program is launched via the CLI. Knowing my Fiance and friends who often use the media PC would give me no end of grief if they had to open a terminal to play movies - I set about finding a solution. Today I'd like to share that fairly simple solution with you!

To allow users to simply "double click" on a media file via the file manager and have it open in OMXPlayer you need to create a .desktop file for OMXPlayer. Open a terminal on your pi and run:

sudo nano /usr/share/applications/omxplayer.desktop

For it's contents paste:

[Desktop Entry]
Type=Application
Name=OMXPlayer
Categories=AudioVideo;Player;
Exec=omxplayer -o hdmi %f
Terminal=true
Icon=emblem-video

Save and close the file (ctrl+x in nano) and you should be good to go! When you double click on a media file in your file browser simply select Open With: OMXPlayer! Please note some users have reported this doesn't work with LXDE - I cannot confirm this though as I only use E17 and it works fine there :)

Cheers,
~Jeff Hoogland

17 comments:

  1. Thanks, Jeff! Useful info. I'll try to get OMXplayer onto the Genesi smarttop once I get back home.
    Flymo

    ReplyDelete
    Replies
    1. Flymo - unless the Genesi hardware has the exact same decoding chip as the RPI this player won't work there.

      Delete
  2. Jeff, did you hear about raspbian? I'm sure you do =)

    Have you considered 'porting' raspbian tweeks, so BhodiPi can have the same performance? or even more, considering it will use EFL?

    ReplyDelete
    Replies
    1. I am working on moving all of Bodhi's ARM releases to ARMHF as I type this. Hoping to have images out next week.

      Delete
  3. Sorry, doesnt work here.

    The OMXPlayer icon appears indeed in the audio&video group, and if I click it directly it shows the black terminal shortly. However If I use a video file with "open with" OMXPlayer, nothing happens. No terminal window appears as well.
    This video file plays OK when I play it using the command line.

    ReplyDelete
    Replies
    1. Odd. You can see this properly implemented in the latest Bodhi for Pi release.

      Delete
    2. I've got the same problem. If I change Terminal value from true to false I can launch videos but without controls...

      Delete
    3. OK, I flashed this bodhi on my Pi. Looking good. Strange, no raspi-config on first boot? Which left me with a qwerty layout :-( I need azerty. Ok, ran the raspi-config to fix that.
      But to my horror I saw this nice looking shell suddenly behaving very buggy, when exploring some config menus. Double mouse cursor, mouse-overs leaving all sort of garbage on the opened panels and on top of that extremely sluggish responsiveness due to all those fancy animations. The pi REALLY needs a lean-and-mean GUI, so I like the Wheezy LXDE shell much more. Due to the erratic behavior I didnt even get to the OMXPlayer trick. Exit Bodhi...

      Delete
    4. Must be a limitation in LXDE then that it doesn't support that option in the .desktop file.

      As for E17 running slowly... It runs just as poorly as LXDE does on my device. The hardware just isn't that powerful - they all run slowly.

      Delete
    5. Well, LXDE does not animate menu's in, it just flashes them up which is more desirable on a slow CPU.

      But the real culprit of this E17 shell is the buggy mouse arrow behaviour, its trashing the window underneath the cursor and making the cursor image itself jumping and duplicating so i don't even see where to click on and it leaves all sort of garbage on the screen. LXDE does not have this behavior. I still have it on the flashcard, I could make a screenshot if that could help you...

      Delete
    6. The menu animation is new to E and is awful. I'm working on disabling/changing it in future updates.

      As for screen tearing/mouse garbage I haven't seen that/can't produce it myself. Can you please post a screen shot and maybe try a different E theme to see if that fixes it? Your image md5sum was good right?

      Delete
    7. After many hours of head-scratching, I arrived at this for the .desktop file - works for me on Raspbian:

      [Desktop Entry]
      Type=Application
      Name=OMXPlayer
      Categories=AudioVideo;Player;
      Exec=lxterminal --command "omxplayer -o hdmi %f"
      Terminal=false
      Icon=/usr/share/icons/nuoveXT2/96x96/categories/applications-multimedia.png

      (Or pick your own icon.)

      Hope it works for you.

      Delete
    8. That works fine for me thanks alot for the headscratching! I can't however get my keyboard to control any aspect of the OMXplayer playback. It wont pause or stop and start or anything for that matter any suggestions ?

      Delete
  4. Unfortunately the above didn't work for me. I am using Raspian. If I use Jeff's solution the files load and play but I have no keyboard control. I'm guessing this will get fixed in time!

    Hope it works for other people.

    ReplyDelete
    Replies
    1. Yall should really go file bug reports with the LXDE folks if this isn't working there. I've only used E17 on my Pi and it works fine there.

      I've gone and added a note to the post that it may not work with LXDE though.

      Delete
    2. I found a fix to the keyboard control.
      Follow this:
      http://stevenhickson.blogspot.com/2012/08/setting-up-omxplayer-gui-on-raspberry-pi.html

      You have to run the command in a new terminal window so that they keyboard commands work properly. It's a pretty simple fix.

      Delete
    3. Everything works fine on my end I have controls and they respond except when I hit q to quit I get a blank screen and my picture is not full screen. I spent many, many hours trying to resolve this but I have no solution.

      Delete