Build a CLI Jukebox with Raspberry Pi
by Troy Scott2014/03/05
For those who are using the Raspberry Pi as a development server there is really no point running a windows manager with raspbian. I run my Raspberry Pi with console access only. Typically login using ssh via a pagekite. But that doesn't mean you can't use the Raspberry PI as a mp3 player.
I used the following setup for the CLI Jukebox:
- Dropbox Uploader for the Raspberry Pi
- Configure Raspberry Pi to output sound to HDMI
- Install mpg321 mp3 player
- Download files to Raspberry Pi using dropbox_uploader.sh
- Play the mp3 files with mpg321
- Enjoy the music
In order to use Dropbox Uploader you will need to create a Dropbox application. Follow the steps in the
Dropbox post. I would create a Dropbox application called jukebox.
Then you can copy your mp3 files into the jukebox folder (/Apps/jukebox). It is probably a good idea to organize them in folders.
Now you can use your laptop or home desktop and copy the mp3 files to the jukebox folder (/Apps/jukebox) in Dropbox. Unfortunately the Dropbox Uploader does not automatically sync the files. Run the dropbox uploader script to do this, assuming that it is installed in your home directory (on the Raspberry Pi):
~/Dropbox-Uploader/dropbox_uploader.sh download /music .
If you want to see how many files are going to be downloaded execute the list command:
~/Dropbox-Uploader/dropbox_uploader.sh list /music
This will provide a list of all the files in the music folder. Because we set our Dropbox applicaton as an App Folder the dropbox uploader script only has access to the files in the /Apps/jukebox folder. Next install the mp3 utility:
sudo apt-get -y install mpg321
Finally we can listen to some music:
mpg321 song1.mp3 song2.mp3 song3.mp3
As you can see it wouldn't take much work to build a bash script or python script to build a small interface for the jukebox. Create playlists by creating shell scripts using the mpg321 command. If you are having trouble getting the sound to work refer back to this article. To have the audio output to HDMI run the command below and then reboot:
amixer cset numid=3 2
The value 2 can have a value between 0 to 2:
- auto = 0
- analog = 1
- hdmi = 2