Mplayer + LIRC: Show elapsed time at the press of a button!

Nov 30, 08:10 PM by Grigorios Prasinos

I am a happy owner of a Macbook (“Santa Rosa”) on which I promptly installed linux (Debian). The Macbook came with a nice infrared remote control which is easily set up in linux with the help of the great LIRC project.
I will not go into the general setup here as it is covered in the LIRC documentation, but instead I will describe how a button on the remote can be bound to more “exotic” functions like displaying the remaining time when using mplayer.

I am assuming that you have already setup mplayer to interface with lirc, so you have some button associations in your .lircrc, like the following:

begin
        prog = mplayer
        button = volup
        config = volume +1
        repeat = 1
end
begin
        prog = mplayer
        button = voldown
        config = volume -1
        repeat = 1
end

The config field specifies a command to be sent to mplayer when the appropriate button is pressed on the remote. The list of the available commands can be found with:

mplayer -input cmdlist

I wanted to make the “menu” button on the remote to display time information, something like <time elapsed> / <time remaining>. Examining the mplayer commands reveals osd_show_property_text which can be used for that purpose. The difficulty then lies in finding the names of the relevant properties which are a bit hidden in the documentation, under the name slave mode protocol. The properties we need are time_pos and length.

Tying it all up, the .lircrc should contain a stanza like the following:

begin
        prog = mplayer
        button = menu
        config = osd_show_property_text "${time_pos} / ${length}"
        repeat = 0
end

And that’s it!

,

---

Comments

 
---