Ubuntu – How to use media buttons for mplayer

mplayer

How can I use my laptop's media buttons [Play/Pause, Next, Previous] to work with Mplayer? The XF86 buttons I think they're called.

Best Answer

Create a named pipe like this:

mkfifo ~/.mplayer/pipe

Then, put the following line in ~/.mplayer/config:

input=file=/home/<username>/.mplayer/pipe

or you can run mplayer with input argument:

mplayer -input file=/home/<username>/.mplayer/pipe

Now use System Setting->Keyboard->Shortcut and add a shortcut with the command parameter as (see mplayer -input cmdlist for the command list):

echo "<mplayer command>" > /home/<username>/.mplayer/pipe

e.g. echo "pt_step 1" > /home/<username>/.mplayer/pipe for next track.

and then assign a key to this shortcut.

Related Question