If you have a spare old computer and electricity bills don’t worry you so much, what do you do? I decided to use mine as my media streaming server. I put my favorite music and movies onto it and initially I simply streamed them to the Wii in my living room and to my laptop. After a while I realized that when I’m cooking I also like to listen to my music (or web radio). So here came the idea to put some speakers on the computer and enable it to a full fledged remotely controlled media player.
The computer runs a copy of Windows Server 2003 and a few other programs. The key program is Remote Process Spawner (RPS), a simple Ruby program that allows the user to define a list of commands to execute on the local machine through a web browser. By leaving RPS running on the server, we make any device within the network that can run a web browser the ability to launch commands (the various media player actions). Once started, a web server is binded on port 8080 (unless we specify otherwise in the command line arguments). If we connect to https://IP_OF_YOUR_SERVER:8080 we can then launch the commands. Which commands? RPS takes a file in .yaml format as input on the command line, which can be modified with a text editor. An extract of my yaml file looks like this:
--- - !ruby/object:ProcessInfo id: 1 name: Play Commercial Music exepath: "C:\playCommercial.bat" arguments: "" keyb: 0x64 - !ruby/object:ProcessInfo id: 2 name: Next Item in Playlist exepath: "C:\winampnext.bat" arguments: "" keyb: 0x6B - !ruby/object:ProcessInfo id: 3 name: Prev Item in Playlist exepath: "C:\prev.bat" arguments: "" keyb: 0x6D
The parameters are straightforward (except for the last one which I will clarify):
- id –> unique integer
- name –> label of the command as shown in RPS
- exepath –> full path of the command to execute
- arguments –> extra parameters to pass to the command
- keyb –> is the Virtual Key Code of the keyboard button associated with the command, as indicated on this page. For example, “Play Commercial Music” is associated with 0x64 which is the numpad 4 button. The user can launch the “Play Commercial Music” either from remote with a web browser or by pressing numpad 4 on the local machine. This feature is only supported on Windows and we need to pass –keybinding enable on the command line when we start RPS to enable it. Otherwise we cannot bind commands to the keyboard (the web browser will still work though).
Each .bat file is a simple batch file that launches Winamp through this very nice plugin. For example, my prev.bat file looks like:
"C:\clamp.exe" /PREV
My playCommercial.bat instead:
"C:\clamp.exe" /START "C:\clamp.exe" /LOADNEW c:\commercial.m3u "C:\clamp.exe" /RANDOM ON "C:\clamp.exe" /NEXT "C:\clamp.exe" /PLAY
Where commercial.m3u is a playlist I created and exported within Winamp. Clamp has several options you can check out by typing:
clamp.exe /?
This allows me to play my own music. What about web radio? Just find a web station and make a batch file that starts a browser on the URL we want:
set firefox="C:\Program Files (x86)\Mozilla Firefox\firefox.exe" @echo off cls taskkill /IM firefox.exe @ping 127.0.0.1 -n 2 -w 1000 > nul start %firefox% "https://www.pandora.com"
We just need to make sure that the automatic updates in browser are disabled (any user interaction will stop the page from loading) and that other dialogs never appear. The taskkill command takes care of killing previous instances of your web radio in case you press the command twice. The ping instruction is a simple trick to put the command line to sleep for 1 second (otherwise we’ll have trouble closing and starting firefox).
So how did we take care of the keypad? If you have enough space I guess you could simply leave a full keyboard attached to the computer and control your media player with it. I didn’t have enough space, so I cut out the whole left part of the keyboard, leaving only the keypad. I took an old PS/2 keyboard, took out the screws, unmounted it and I cut the plastic with the aid of a 30W soldering iron and a “customized” iron tip, which I made by beating it up with a hammer onto a metal surface until I obtained a nice cutting shape. Once you warm up the soldering iron the plastic melts like butter. You have to try it.
With a pair of scissors I also cut the circuit layout grid inside the keyboard to leave me only the right part. Fortunately the PS/2 controller was located on the top right part of the keyboard, which allowed me to put the screws back in place to get me a working PS/2 keypad!
I attached the keypad onto the computer, rebooted, started RPS after setting up my playlists and web radio URLs and there we go. Now I can cook and listen to my music. How about using an iPod instead?