Mediaplayer Web-Interface
June 13th, 2008 admin
Today I finished the first version of my current hobby programming project. The goal of my project was to realize a mediaplayer based on a old but silent Desktop PC. I wanted this PC to host my MP3/Ogg music collection and to provide a very simple interface. I wanted the interface to be accessible from my workstation and from other remote devices - like a iPhone or Windows Mobile based devices - so that I could move the mediaplayer into a corner or my room - or into the basement.
A decided not to write another software mediaplayer but to concentrate on the interface. There are already tons of great players available as Open Source - so why not utilize them? So I made this design for my project:
The music files are stored in a folder on the local filesystem. The information about artist, album, track etc get extracted using a simple Perl script. This data is then imported into a PostgreSQL database.
The user interface is realized in Perl, too. It’s a simple CGI application hosted on a thttpd webserver. The interface offers a simplistic search page. The search is wrapped into SQL queries and send to the PostgreSQL server. The results are rendered as browsable lists. The user can either select single songs, all songs for a specific album or all songs of a specific artists. The selection will be stored as a playlist that gets persisted in the database, too.
When a songs gets played and the player finishes, one normally wants the player to start the next song in the playlist. Therefore a daemon process is necessary that watches over the playback, starts it and stops it. I decided to write this daemon in Java because Java offers a good threading API and good network support. One thread of the application watches over the Linux commandline mediaplayer used to play the files (mpg123 and ogg123 in this case). A second thread is used to implement a webserver interface to make the interprocess communcation as painless as possible. Using the integrated webserver the CGI application can start the playback of the next song in the playback with a simple query to http://localhost:8000/start. That’s nice
I added some more features every jukebox should have: volume control and a sleeptimer. As noted initially the software is finished now. I installed Xubuntu 8.04, thttpd, PostgreSQL, Perl, mpg123 and ogg123 and my scripts on the box, tweaked the user rights to allow the remote shutdown, copied my music archive onto a second partition and imported it into the database. The installation was a little tricky - but I think that’s OK when I’m be the only customer
I’ve tested the player for about a week now and it performs nice - no big problems so far. Here are some more screenshots to give you a impression of the software.

This is the default page of the interface displayed in Mozilla 1.7.

You can search for artists, albums and songs. The results are displayed as lists.

The result list is played inside a frame so that you never have to scroll to use the command buttons.

This is the playlist. Items can be removed using the “-” icon.

The volume can be adjusted using a JavaScript based slider. On the inside aumix is used to control the volume.

This is the interface for the sleeptimer. It’s a nice feature when you can listen to the music while you’re in bed and you do not have to stand up again to turn the computer off. Once the timer has been set the remaining time will be displayed here. Of course you can always cancel the timer.
Posted in Uncategorized | Comments Off

