Software

Linux Muzack Player

This code is based on what I use to manage all my music.

Due to a minor lack of planning I ripped most of my CDs using the Windows Realplayer, which stored the stuff in various proprietary formats that can't be played with the usual range of MP3 players. Then I decided to connect my linux machine to my stereo so that we could hear these ripped tracks via something rather better than the tinny PC speaker. Unfortunately I then discovered that the linux realplayer is complete pants and doesn't do useful things like support playlists.

So I decided to write a control program for the linux realplayer. Given the practically non-existent documentation I did this the crude way by spawning off one realplayer instance and checking every half a second or so to see if it has finished playing and quit, and if so starting up another one to play the next track. In theory there is a better way to do this using the --embedded option but with no documentation readily to hand it seemed easier to do it this way

The control program runs as a server and is itself controlled via commands sent on its control TCP port (by default 9000). The truly hackerish may wish to control this by other means but my prefered method of control is a cgi script running on the webserver that is also present on my linux box. The cgi-script and webpage it produces is relatively simple and more advanced ones (with, say, music categorization capabilities) are left as an exercise for the student.

Example: You can see a (non functional) example of what the cgi controller here.

Requirements: A linux box with realplayer, a web server a lot of music in rmj, m4a or mp3 format and perl. Since I use the xampp web bundle it is possible that at various points the scripts make reference to some file relationship which does not hold in other environments, but I believe the only place where this is the case is the perl path on the initial line of each script

Installation: Download the tar file and extract to a temporary directory

Put the muzacksvr.pl file in the root directory of your music collection or in the /bin directory of your choice and the muzack.cgi file in the web server's cgi-bin directory. Make sure both have appropriate permissions and edit to correct the perl path. If the music directory is not /opt/My Music/ then you will need to edit the files appropriately.

Usage: Start a shell and run muzacksvr.pl. It should report "Starting Server" and then "Quiet" because there is no realplayer instance running. Fire up a webbrowser and go to http://localhost/cgi-bin/muzack.cgi. You should see a rather empty screen stating that the status is "Quiet", a large empty box and some buttons. Before you can play anything you will need to tell the daemon script to search for music by clicking on the Rescan Music button.

I hope the various buttons are fairly self-explanatory. Once you have some music you can select one or more of the tracks and then the "Add to Playlist" button to start playing them. If you make a mistake then Clear Playlist will remove all tracks from the queue (but if a track is playing it won't clear that one - you just have to wait or manually close realplayer. The webpage reloads by default every 60 seconds but if you want a more recent update then the current status button is for you. Normally you wil not need to either stop or restart the daemon but it can be handy if you are hacking the script a bit.

Creative Commons License
This realplayer controller is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.

Site Home and Software Home