Emiror Jukebox

Touch Screen MP3 Jukebox


Introduction

What is it?  Well, basically it is a Jukebox written in Java to play MP3s.  It can be used with any type of pointing device including a mouse, but it was written with the idea of using a touch screen to select and queue up songs to play.  And I recommend a touch screen for maximal enjoyment.

It would have been fairly simple to just run XMMS or X11AMP if all I wanted was music, but I wanted the system to be a real jukebox that even the most computer illiterate person could be able to use.  I wanted the person to be able to find the song they wanted, then add it to the end of a queue.  One of the most annoying things to me is when someone cuts off a song that is playing so that they can listen to the song they want.  With this system, you could queue up a bunch of songs, walk away and have them play in order.

 

Why Java?

I decided to use Java for several reasons.  First it is platform independent, and thus could be used on a wide variety of architectures, everything from Windows to Linux to a PDA.  Basically anything with a Java Virtual Machine (JVM)  Next I did not want the user interface to look anything at all like a normal computer user interface.  I wanted my own completely customized widgets and skin.  I could do this easily in Java by looking at the source code for the Swing UI and changing it to suit my needs. 

 

Background

I was sitting in my favorite bar (PK's in Blacksburg, VA) one evening enjoying a beer and listening to some tunes. I've always liked the jukebox system they have there, it's called TouchTunes. It is basically a stand up jukebox with a 17" touch screen for selecting songs. Much nicer than flipping through a bunch of small printed labels behind a glass window.

In a stroke of alcohol induced brilliance I conjured up an idea. I would simply steal this jukebox and put it in my living room. Oh I could imagine the ensuing parties and women throwing themselves at me already! After repeated attempts by me to take the thing to my car resulted in a total movement of about 2 inches, I decided I'd have to try another approach. When threatening the bouncer with a butter knife to get him to help carry it only ended up with my friends and I getting rudely asked to leave, I reluctantly resolved to programming my own jukebox. And it would be better than theirs damn it! Oh how they would rue this day.

 

Hardware

First things first, I needed a touch screen monitor.  I wanted something that would work under linux, because that was going to be my operating system of choice because I wanted to control the dang thing remotely and I can't have it crashing all the time.  Touch screen support in X11 seemed to be geared to either an Elographics or a MicroTouch screen.  I wanted to try and use one of these two rather than write my own touch screen drivers because I'm lazy and would rather have it done for me :).  I looked at how much they wanted for a new touch screen and choked.  Me being a poor college student couldn't afford to waste too much beer money.  Therefore I decided to hit Ebay and find me a cheap used one.  I ended up getting a MicroTouch 14" SVGA monitor with a max resolution of 1024x768 for about $80.

The next component was a machine to handle my little project.  I needed it to run linux, X11, my program, and mpg123 without any skipping from cpu load.  My roommate had an extra Celeron 300a sitting around, so I appropriated it for my mission.  The cpu load on the system rarely gets over 5% usage, so you could probably use something along the lines of a Pentium 100 or something like that.  Your mileage will vary I'm sure.

You will need a decent sound card as well.  I originally used a very old SoundBlaster 16 card, and although it worked fine, it did cause feedback in the stereo, resulting in a low pitched hum.  I've since changed it to an AWE64, and it sounds perfect now.

Finally you will need storage of some kind for all those mp3s you're gonna load this puppy up with.  Instead of storing my songs locally, I have them stored on my Windows 2000 machine.  I hooked the jukebox up to the network and used Samba to mount the folders over the network.  Works quite well.

 

Software

I'm running Red Hat 6.2 linux on the machine.  Make sure to install Samba on it if you're going to share the songs from a Windows machine, otherwise NFS might be a good choice for a *nix machine.  If you are using a relatively recent version of XFree86, they have touch screen capability built in, using Xinput.  If you need help getting it to work, you can check out the HOW-TO.

My software needed a way to play the MP3s, and I really didn't want to write my own mp3 decoder and player, so I found two solutions.  The first one being a Java library called JavaLayer.  The advantage to this method is that it is compatible, and would work on any machine.  The disadvantage is that it takes up much more CPU power than a native player, and thus has to be run on a fairly fast machine.  The alternative was to use a native player.  For this I decided to use MPG123, which can be compiled for both Windows, and more importantly in my case, for Linux.  The disadvantage of course was portability.

I did however run into a slight problem using the MPG123 player.  If the mp3 you are trying to play has frame errors in it, it causes the player to immediately quit and not attempt to play past the error.  No good!  I didn't want to have to do it, but I had to start hacking into the mpg123 code to fix this.  I took a look at XMMS, which did not quit on the songs with errors and noticed that it used a modified version of mpg123 as an input module.  I took some of the code from this project slapped it in common.c and modified it a bit to make it work.  This seems to solve the problem.  That's why I love open source...if there's a bug/problem, you can solve it yourself.

And since the jukebox was written in Java we would need a Java Virtual Machine (JVM) of course.  I'm using Sun's Java 2 SDK 1.3 for linux.  If you don't plan on compiling or changing any of the code, you can use the Java 2 JRE 1.3 instead.  The program does use Swing, so you need at least version 1.2 or 1.1 with Swing extensions (If you are using something this old, you might just want to upgrade to 1.3 anyway).  

 

Screenshots

What you've all been waiting for, some screen shots.  Click on the thumbnails for a larger view.
Screenshots will appear in a new browser window.
The main screen from which you can select songs to queue up.
The list of queued songs.  If you click on one it will remove it from the queue.
The control panel can be password protected so only you can delete songs or exit the program.  Good for parties so nobody cancels your favorite song to listen to the latest boy-band crap song. 

 

Where can I get the Jukebox?

You can download the jukebox in two different ways.  The precompiled classes in a JAR file, or the source code.  Please use the zip file if you are going to run it on windows, and the gzipped tar if you are running it in linux, so you can get the correct file permissions on the scripts.

Precompiled Classes

Source Code

The player comes with the JavaLayer player included.  This is alright to use if you have a fairly fast computer, but I'd recommend using a native player for increased performance.  You can use any player you desire, so long as you can invoke it from the command line, and it exits after it is done playing the song.  The format expected is "player song.mp3".  If it doesn't work like that or you need to pass options, you'll need to write a script (Hint: take a look at mpg123.sh).

Below I've included binaries for MPG123 and Wav for windows.  I've also included an ELF binary of mpg123 for linux and the modified source code to play through frame errors in some MP3s.

Windows

Linux