Topic: Control VLC Using Multimedia Keys

13.04.2011 - Update :  IF you have stumbled across this post please check this new one about using a Unix socket which works better  http://crunchbanglinux.org/forums/post/112035/#p112035

VLC has plenty of options for using shortcut keys however these only work when the VLC interface has focus.  I am not aware of an easy way to control VLC using multimedia key bindings when it does not have focus so I did some searching and found this article:

It's a little bit hackish but it works.

I then created this script:

vi ~/bin/controlvlc.sh
#!/bin/bash

case $1 in

        next) A="wget -q -t 1 -O - http://127.0.0.1:8080/?control=next" ;;
        prev)  A="wget -q -t 1 -O - http://127.0.0.1:8080/?control=previous" ;;
        play-pause) A="wget -q -t 1 -O - http://127.0.0.1:8080/?control=pause" ;;
        stop) A="wget -q -t 1 -O - http://127.0.0.1:8080/?control=stop" ;;
        *) echo "Usage: $0 { next | prev | play-pause | stop }" ;;

esac

exec $A
chmod +x ~/bin/controlvlc.sh
  • Open VLC.

  • Go to:  Tools > Preferences > Change "Show Settings" to "All" > Interface > Main Inteface > Select "HTTP remote control interface".

  • Click Save.

  • Restart VLC.

Add the following to the "<!-- Keybindings for running applications -->" section of Openbox's rc.xml

vi ~/.config/openbox/rc.xml
    <keybind key="XF86AudioPlay">
      <action name="Execute">
        <execute>controlvlc.sh play-pause</execute>
      </action>
    </keybind>
    <keybind key="XF86AudioNext">
      <action name="Execute">
        <execute>controlvlc.sh next</execute>
      </action>
    </keybind>
    <keybind key="XF86AudioStop">
      <action name="Execute">
        <execute>controlvlc.sh stop</execute>
      </action>
    </keybind>
    <keybind key="XF86AudioPrev">
      <action name="Execute">
        <execute>controlvlc.sh prev</execute>
      </action>
    </keybind>

Reconfigure Openbox and try your multimedia keys in VLC.

Cheers!

Last edited by jelloir (2011-04-13 12:19:20)

Re: Control VLC Using Multimedia Keys

Nice, let me try this on my box big_smile big_smile Have been looking for this for quite a long time..

Thanks for sharing smile

Thanks for everything Linux has taught, is teaching, and will teach me...

Re: Control VLC Using Multimedia Keys

mmhhh.. It doesn't work for me hmm
if I launch vlc in a terminal the output is:

 vlc
VLC media player 1.0.6 Goldeneye
[0x8713b08] main interface: creating httpd
[0x8713b08] main interface error: socket bind error (Permission denied)
[0x8713b08] main interface error: socket bind error (Permission denied)
[0x8713b08] main interface error: cannot create socket(s) for HTTP host
[0x8713b08] http interface error: cannot listen on :8080
[0x8713b08] main interface error: no suitable interface module
[0x86588a8] main libvlc error: interface "http,none" initialization failed
[0x86588a8] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.

(<unknown>:21173): Gtk-WARNING **: Impossibile trovare il motore del tema in module_path: «pixmap»,

What can i try?

Re: Control VLC Using Multimedia Keys

I solved my problem big_smile I had other instance of vlc: I killed all and now seems to work.

Thanks

Re: Control VLC Using Multimedia Keys

very nice.

eee701/4gb/512ram

Re: Control VLC Using Multimedia Keys

Thank you for this.

Re: Control VLC Using Multimedia Keys

Hi,
  Thanks to the original poster. I have Statler X64 running and this little routine gives me VLC Multimedia control from my HP DV5 Pavillion - using the "Quickkeys."
   
    Super!

Re: Control VLC Using Multimedia Keys

Um...

I solved this problem by going into the VLC preferences > Hotkeys, double-clicking on the "Global" column of whichever shortcut you want, then pressing the key you want to use roll.

Maybe OP had an older version on which this didn't work, but it's still worth mentioning.

Re: Control VLC Using Multimedia Keys

strolskon wrote:

Um...

I solved this problem by going into the VLC preferences > Hotkeys, double-clicking on the "Global" column of whichever shortcut you want, then pressing the key you want to use roll.

Maybe OP had an older version on which this didn't work, but it's still worth mentioning.

see original post...

jelloir wrote:

VLC has plenty of options for using shortcut keys however these only work when the VLC interface has focus.

In any case the guide at http://crunchbanglinux.org/forums/post/112035/#p112035 is better to use.

Re: Control VLC Using Multimedia Keys

jelloir wrote:

see original post...

jelloir wrote:

VLC has plenty of options for using shortcut keys however these only work when the VLC interface has focus.

No they don't. There are hotkeys, which work when VLC has focus, and "Global Hotkeys", which work even if it's in the background.

Re: Control VLC Using Multimedia Keys

strolskon wrote:

No they don't. There are hotkeys, which work when VLC has focus, and "Global Hotkeys", which work even if it's in the background.

This works in #! Openbox?

Re: Control VLC Using Multimedia Keys

It does in mine.

Re: Control VLC Using Multimedia Keys

^ Doesn't in mine. Just attached a PS/2 keyboard with various multimedia/audio keys. "xev" shows/detects these XF86Audio keys and VLC allows me to allocate them as "global" hotkeys, but pressing them does nothing (whether VLC has focus or not) sad I'm referring here to stop, play/pause, next track and previous track; volume up/down and mute work (but this is via the volume control icon/applet I think). Surely we don't need to hack away with the bash scripts in the first post if VLC is detecting the keypresses... ?

Last edited by SabreWolfy (2012-03-10 09:04:11)

Re: Control VLC Using Multimedia Keys

Post here indicates this was solved by installed "xfce4-volumed". I installed this and then ran "xfce4-volumed" but nothing changed. Position keys still don't control VLC.

Last edited by SabreWolfy (2012-03-10 09:14:16)

Re: Control VLC Using Multimedia Keys

Just in case I wasn't clear before -- pressing the positional XF86Audio keys in VLC to set them as "Global" hot-keys is working...

http://ompldr.org/tY3puOQ

And "xev" is showing details when I press them. However, pressing them at a later time to actually use them is not working.

Re: Control VLC Using Multimedia Keys

Solved.

By. Restarting. VLC.

roll

Re: Control VLC Using Multimedia Keys

When "xfce4-volumed" is running though, a cool notification pop-up appears briefly when changing the volume with the XF86Audio keys smile

Re: Control VLC Using Multimedia Keys

However, when "xfce4-volumed" is running, the hotkeys under the volume icon | Preferences cannot be changed and/or stop working.