mplayer-remote
Download: mplayer-remote v0.0.3
Introduction
A remote control for mplayer...
From time to time, I watch a movie on my computer. Actually, I have neither television nor dvd player (and certainly no more recent player), so that whenever I watch a movie, it's a dvd on my computer. Thankfully, I do have a large screen.
So now when I watch a movie, I sometimes want to do things like pausing the movie, or reducing the volume if my daughter is failing to fall asleep, etc. These things can be done using a keyboard, but the fancy devices they invented a few decades ago, called "remotes", are actually really nice for the abovementioned purposes. Unfortunately, my computer has no IR receiver, and I have no remote control device. However, I do have a smartphone. And so --- wait for it! --- the genius idea here is that I can actually control my dvd player (in this case, mplayer) and a few external things, such as the volume and ejecting the dvd tray, using my smartphone. The whole setup is quite similar to MyWebPlayer, but it runs as the user and does not require having any web server running, so it's easier to set up. It doesn't look as slick, though!
This little script is a very simple web server, using port 8080, that runs as long as mplayer is running. The server runs as the user running mplayer (so there are no safety issues in that respect), and creates a unix pipe to control mplayer. This allows functions such as pausing/restarting the playback, skipping forward and backward in the movie, etc. And since the whole interface is seen as a web page, no software needs to be installed on the smartphone. It would be possible to control the computer from anywhere over the internet if my NAT/firewall setup allowed that (and, although pointless, this could be quite cool), but I only allow access on the local WIFI network. For convenience, I did not implement any authentication methods (I don't want to enter a login and password each time I want to watch a movie), so safety should be ensured by other means.
Incidentally, I suppose this also means that mplayer-remote could also be made to work under windows, by using standard input instead of the fifo. I haven't got access to a windows machine, so if anyone could try this and let me know how it goes, I'd be most grateful...
Installation and usage
To install, simply make sure that python is installed on your
computer with the BaseHTTPServer and PIL modules, and copy
the mplayer-remote
file to somewhere in your
path. Then, simply use mplayer-remote as if it were mplayer
itself; all command line arguments are simply passed on to the
sub-process and keyboard and mouse still work as before. For
example:
mplayer-remote dvd:// -alang en -fs
The only difference with directly running mplayer is that you now can access a web page at the IP address of your machine. To make this easy, you can call mplayer-remote as follows:
mplayer-remote -qr dvd://
which will display a QR code. Scan this code with your cell phone, and hopefully you will automatically be directed to the correct IP address and port number. Notice that if you don't have an mplayer-remote running while you do this, you will get an error. Just start your movie and reload the web page. In practice, you probably do not need to scan the QR code each time you reboot your machine, as its IP address is probably quite stable even if you use DHCP. So it probably makes sense to save a bookmark to the remote control web page.
The resulting interface looks as in the image. This may seem a bit dark, but while watching a movie it is actually quite comfortable. If your cell phone has an OLED display, it is also quite energy-efficient, since the black pixels don't consume any power.
The controls are as follows. The bar at the top shows the current volume setting (in this case, 80%). Below that are a number of buttons to set the volume to fixed values (25%, 50%, 60%, etc.), and the buttons below that decrease the volume by 2%, increase it, or mute it.
The video controls allow pausing/restarting the movie and skipping forward and backward through the timeline. The last two buttons eject the drive and quit the server. If mplayer is started with dvdnav://, dvd navigation buttons are also created, allowing you to browse through the dvd menu.