VLC HowTo/Use with lirc

From VideoLAN Wiki
Revision as of 17:55, 29 January 2007 by Xtophe (talk | contribs) (use how-to template)
Jump to navigation Jump to search
This page describes how to to use VLC media player with an infra red remote control. Other "how to" pages

The aim is to have your remote behave the same way as for a television remote: program +/-, volume +/-, jump to position 3 when button 3 is pressed,...

Build-in lirc commands are only for basic control in the movie-playing mode, but I need to use other commands from rc interface - mainly "goto x" function. So the goal was to be able to use goto function with lirc.

VLC

Use a VLC version with lirc enabled.

Start-Up Script

#start/stop script for lircd+vlc for Kubuntu 6.10
start() {
   echo "Starting lirc support..."
   sudo setserial /dev/ttyS0 uart none       #serial port down
   sudo /sbin/modprobe lirc_serial           #load module
   sudo /sbin/modprobe lirc_dev           #load module
   sudo /usr/local/sbin/lircd --driver=default --device=/dev/lirc0 --output=/dev/lircd --pidfile=/var/run/lircd.pid --listen  #run lirc daemon
   sudo chmod 666 /dev/lircd                 #access
   sudo irexec -d   #daemon to pass ir commands
}

stop() {
   echo "Stoping lirc support..."
   sudo /usr/bin/killall -w lircd                #kill lirc daemon
   sudo /sbin/rmmod lirc_serial              #unload module
   sudo /sbin/rmmod lirc_dev                 #unload module
   sudo setserial /dev/ttyS0 uart 16550A     #serial port up
}

restart() {
   stop
   sleep 2
   start
}

case "$1" in
'start')
  start
  ;;
'stop')
   stop
   ;;
'restart')
  restart
   ;;
*)
echo "usage $0 start|stop|restart"
esac
exit 0

Scripts

It is neccesary to run vlc with rc interface to use all the supported commands (see vlc help). I use this script to run VLC with rc intf. Lircd is loaded and later unloaded. I have a desktop shortcut icon and I had to change properties of the shortcut to run in terminal. The other option is vlc --fake-tty option, but this uses 100 % CPU :-(

#/bin/bash
/home/ondra/.vlc/ovladac.sh start
vlc -I rc --rc-host localhost:12345 /home/ondra/playlist.m3u   
/home/ondra/.vlc/ovladac.sh stop

I use irexec to pass commands to VLC rc intf. Commands can be passed with netcat: echo "vlc_rc_command" | netcat localhost 12345 -q 1 (q means quit after 1 s). Commands are written in scripts, which are executed with irexec:

Here is a script, which is executed when remote button 1 is pressed. The others are similar.

cat play1.sh
#!/bin/bash
echo "goto 0" | netcat localhost 12345 -q 1

.lircrc

The last part of the .lircrc file.

There are defined actions for all requested buttons. irexec executes concerned shell script.

# remote numbers
begin
        prog = irexec
        button = 1
        config = /home/ondra/.vlc/play1.sh  &\n
end

begin
        prog = irexec
        button = 2
        config = /home/ondra/.vlc/play2.sh  &\n
end

begin
        prog = irexec
        button = 3
        config = /home/ondra/.vlc/play3.sh  &\n
end

begin
        prog = irexec
        button = 4
        config = /home/ondra/.vlc/play4.sh  &\n
end

begin
        prog = irexec
        button = 5
        config = /home/ondra/.vlc/play5.sh  &\n
end

begin
        prog = irexec
        button = 6
        config = /home/ondra/.vlc/play6.sh  &\n
end

begin
        prog = irexec
        button = 7
        config = /home/ondra/.vlc/play7.sh  &\n
end

begin
        prog = irexec
        button = 8
        config = /home/ondra/.vlc/play8.sh  &\n
end

begin
        prog = irexec
        button = 9
        config = /home/ondra/.vlc/play9.sh  &\n
end

begin
        prog = irexec
        button = 0
        config = /home/ondra/.vlc/play0.sh  &\n
end
begin
        prog = irexec
        button = Menu
        config = /home/ondra/.vlc/pause.sh  &\n
end


Version

This has been written by [User:J-b] using Ondřej Kuda's HowTo.

See also

Original post on VideoLAN forum

Gentoo Wiki's HowTo

Enhanced VLC lirc remote control