3.3. Control

MPlayer has a fully configurable, command driven, control layer which lets you control MPlayer with keyboard, mouse, joystick or remote control (using LIRC). See the man page for the complete list of keyboard controls.

3.3.1. Controls configuration

MPlayer allows you bind any key/button to any MPlayer command using a simple config file. The syntax consist of a key name followed by a command. The default config file location is $HOME/.mplayer/input.conf but it can be overridden using the -input conf option (relative path are relative to $HOME/.mplayer).

You can get a full list of supported key names by running mplayer -input keylist and a full list of available commands by running mplayer -input cmdlist.

Example 3.1. A simple input control file

##
## MPlayer input control file
##

RIGHT seek +10
LEFT seek -10
- audio_delay 0.100
+ audio_delay -0.100
q quit
> pt_step 1
< pt_step -1
ENTER pt_step 1 1

3.3.2. Control from LIRC

Linux Infrared Remote Control - use an easy to build home-brewed IR-receiver, an (almost) arbitrary remote control and control your Linux box with it! More about it on the LIRC homepage.

If you have the LIRC package installed, configure will autodetect it. If everything went fine, MPlayer will print "Setting up LIRC support..." on startup. If an error occurs it will tell you. If there is no message about LIRC there is no support compiled in. That's it :-)

The application name for MPlayer is - surprise - mplayer. You can use any MPlayer commands and even pass more than one command by separating them with \n. Do not forget to enable the repeat flag in .lircrc when it makes sense (seek, volume, etc). Here is an excerpt from a sample .lircrc:

begin
     button = VOLUME_PLUS
     prog = mplayer
     config = volume 1
     repeat = 1
end

begin
    button = VOLUME_MINUS
    prog = mplayer
    config = volume -1
    repeat = 1
end

begin
    button = CD_PLAY
    prog = mplayer
    config = pause
end

begin
    button = CD_STOP
    prog = mplayer
    config = seek 0 1\npause
end

If you do not like the standard location for the lirc-config file (~/.lircrc) use the -lircconf filename switch to specify another file.

3.3.3. Slave mode

The slave mode allows you to build simple frontends to MPlayer. When run with the -slave option MPlayer will read commands separated by a newline (\n) from stdin. The commands are documented in the slave.txt file.