How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use

How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use

You have a lot of options for accessing your computer’s music library from your stereo, but most require technical know-how to use. You can build a jukebox with a Raspberry Pi, a tiny micro-computer, that anyone can use, even if they don’t know what a Raspberry Pi is.

When you’re done with this project, you’ll have a tiny, touchscreen jukebox in your living room that can play, control and pick songs from your music library on another PC (or your network attached storage), then play them on your stereo. The interface here is easy to understand, so it’s great for parties or a house where a few non-geeks might want to get in on the playlist without learning a complicated system. Better still, it all works on its own network, so there’s no need to worry about pairing devices. To finish this project, you’ll need a little knowledge of the command line, but that’s it.

What You’ll Need

Step 1: Install Raspbian on the Pi

First things first: you’ll need to set up and install Raspbian. If you’re using the PiTFT touch screen display I did, it’s a lot easier to set it up with Adafruit’s custom Raspbian image. You’ll install the image on your SD card the same way as with Raspbian, but the operating system will already be configured for the display. You can follow our guide to make an image here, but here’s the short version:

Windows

  1. Download the latest version of Raspbian and unzip the .img file inside.
  2. Download Win32DiskImager and unzip the application (.exe file) inside.
  3. Insert your SD card into your Windows PC using a card reader.
  4. Open Win32DiskImager.exe, the application you just downloaded, by double-clicking on it. If you’re running Windows 7 or 8, right click on it and choose “Run as Administrator” instead.
  5. If your SD card isn’t automatically detected by the application, click on the drop-down menu at the top right (labelled “Device”) and choose it from the list.
  6. In the image file section of the application, click the little folder icon and choose the Raspbian .img file you just downloaded.
  7. Click the Write button and wait for Win32DiskImager to do its thing. When it finishes, you can safely eject your SD card and insert it into your Raspberry Pi.

OS X

  1. Download the lastest version of Raspbian and unzip the .img file inside.
  2. Download RPi-sd card builder (be sure to pick the appropriate version for your installed version of OS X) and unzip the application.
  3. Insert your SD card into your Mac using a card reader.
  4. Open RPi-sd card builder. You’ll immediately be asked to choose a Raspbian image. Choose the .img file you downloaded earlier.
  5. You’ll be asked if your SD card is connected. Since we inserted it earlier, it is, so go ahead and click Continue. You’ll be presented with SD card options. If you only have one inserted, you won’t see anything else in the list and it will be checked. If not, just check only the card you want to use and click OK.
  6. Enter your administrator password and click OK.
  7. You’ll be asked if the SD card was ejected. This is supposed to happen, as the application needs to unmount it so it can perform a direct copy. Double-check that your SD card is no longer available in the Finder. DO NOT remove it from your USB port. When you’re sure, click Continue.
  8. RPi-sd card builder finishes prepping your SD card, safely eject it and insert it into your Raspberry Pi unit.

Step 2: Hook Up Your Display

How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use

The Raspberry Pi has a GPIO (general-purpose input/output) that the touch screen fits into. If you look at your Raspberry Pi, it’s the set of pins on the corner. If you haven’t already, go ahead and click the display onto your Raspberry Pi. When it’s hooked up, plug in your keyboard, ethernet cable (or Wi-Fi adaptor), then the power cable. You’ll be asked to calibrate the touchscreen. Follow the on-screen instructions, and you’ll be all set.

Step 3: Share Your Computer’s Music Library

How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use

Before you start working on the Raspberry Pi, you should set up music sharing on your home computer. The process is different for both Windows and Mac.

Windows

  1. Navigate to your computer’s music folder.
  2. Right-click the folder and select “Share with” and select domain. If you’re only on a home network, you can keep it public and it will only be available to other computers on your home network. Otherwise, select the password protected sharing, then enter a password.
  3. Make a note of the folder’s location and your computer name (It will be something like ThorinPC/Music).

Mac

  1. Open up System Preferences.
  2. Click the “Sharing” icon.
  3. Make sure the “File Sharing” box is checked.
  4. Click the “+” underneath shared folders, select your music folder, then click “Done.”
  5. Back on the Sharing menu, select “Options…”
  6. Select “Windows File Sharing” and enter your password. This will make it easy for the Raspberry Pi to grab your files.

Now that your home computer’s sharing its music library, you can return to your Raspberry Pi.

Step 4: Install and Configure MPD

The foundation of this project is Music Player Daemon (MPD). It’s a server-side application for playing music. This means it has no graphic interface, it simply allows your Raspberry Pi to play music files. You won’t need to dig around in the command line to actually use this project once it’s set up, but you will need to for the initial setup process. First, you’ll need to download MPD and MPC (the controller). When you booted up your Raspberry Pi earlier, you should have ended up at the command line after the touchscreen calibration. If not, and you’re in Raspbian, tap the menu icon and select “Log Out”. You’ll do all the work in this guide from the Raspberry Pi’s command line, type in:

sudo apt-get install mpd mpc

Wait for that to install. Once it’s finished, you should change a couple of settings by running:

sudo nano /etc/mpd.conf

Find the line that starts with:

 #zeroconf_enabled “yes”

and delete the # in front of it to uncomment it. Press CTRL+X and select Y to save and exit.

Step 5: Set Up the Music Library

Next up, you’ll need to point MPD to your music library. For this, you’ll make a folder, then mount your music library in it. You’ll need to do most of this with the sudo command because you need root privileges to get everything installed and working properly. Start by making a folder:

sudo mkdir /mnt/music

Next, we’ll make sure it mounts when the Pi boots. Run this:

sudo nano /etc/fstab

Then add this line, substituting Computer name with the info and /folder name you gathered in step three for your music folder location:

//Computername/foldername /mnt/music cifs guest,uid=1000,gid=1000,iocharset=utf8 0 0

It should look something like this:

//WindowsPC/music /mnt/music cifs guest uid=1000,gid=1000,iocharset=utf8 0 0

Note: if you require a login to your shared folders, you’ll also need to replace guest with username=yourusername,password=yourpassword.

When you’re done, tap Ctrl+X to save and exit. Next, let’s test and make sure the mount is working properly. Type in:

sudo mount -a

If you don’t get an error message, it’s mounted correctly. Now go ahead and take a quick look to make sure all your music files are there. Run this command:

ls -l /mnt/music

You should see all your music files. If that’s all in order, you’ll need to create a symbolic link for MPD so it knows where to go looking for those files. Type in:

sudo ln -s /mnt/music /var/lib/mpd/music

Now, MPD should be all set. You just need to scan your music library to get everything in there. Type in:

mpc update

Depending on the size of your library, this will take a little while, so let it do its thing.

Step 6: Configure Networking and USB Drive Access

Next up, you’re going to configure Zeroconf, which will allow you to control your jukebox from other devices if you don’t feel like walking over and using the touch screen. Type in:

sudo apt-get install libnss-mdns

When that’s complete, start it up:

sudo service avahi daemon restart

Now you can optionally use a mobile phone app like MPDroid for Android or MPDluxe for iOS as a remote control for the Pi Jukebox. Before we get to that, you can also set up the jukebox to read files off a connected USB drive, which is handy if friends come over with a bunch of MP3s on a flash drive. Sadly, you can’t just plug in your phone to get access to the music because chances are the Raspberry Pi won’t be able to recognise it. To turn on USB support, type in:

sudo apt-get install usbmount

Then point MPD to the USB sticks:

sudo ln -s /media/ /var/lib/mpd/music/

That’s it. You should be able to play music from just about anywhere now.

Step 7: Install the Jukebox Software

Right now, your Pi can access your music and play it from the command line. That’s pretty boring. Let’s get the nifty touchscreen interface set up.

We’re going to use a program called Pi-Jukebox for this. It’s essentially a frontend for MPD that allows you to use the touchscreen to control music playback. Installation here is pretty straightforward. From the command line, run:

git clone https://github.com/mark-me/Pi-Jukebox

This downloads all the files needed to the Raspberry Pi and into the Pi-Jukebox folder. Before we can run it, we need to install Python:

sudo apt-get install python-pip

Once that’s installed, it’s time to run the Jukebox program.

Step 7: Run and Use the Jukebox Software

To launch the jukebox, you only need to type in one command:

sudo python pi-jukebox.py

If everything goes as planned, you should now see the Pi-Jukebox software on your touchscreen. Here’s a breakdown of what each button means:

How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use

For the most part, the interface works as you’d expect. You can swipe up and down to browse your library, tap on any of the controls to start and stop play, and tap on a selection to load it up. Pi-Jukebox works just like a jukebox, so you’ll add each of your selections to a currently playing playlist and go from there. There isn’t a direct means to simply play an album without adding it to a playlist.

The settings options are pretty straightforward as well, but it’s worth popping in there and checking them out. You can set up your jukebox to shuffle, repeat tracks and more. But for all intents and purposes, you’re set up and ready to start listening to music. If you haven’t already, connect your Pi into your stereo and start jamming.


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


3 responses to “How To Build A Raspberry Pi Jukebox Any Non-Geek Can Use”