Build a wall-mounted "SqueezePlayer"-based network music player using Squeezelite, Jivelite and a Raspberry Pi. I built this project because Logitech has stopped making its "Squeeze" line of networked music players. Since the server software is open source, and because I continue to have several network players around the house that only work off of the Logitech Media Server (originally called the Squeezebox Server), and finally because a few intrepid souls in the Squeeze forums (http://forums.slimdevices.com/showthread.php?97046-Announce-Squeezelite-a-small-headless-squeezeplay-emulator-for-linux-%28alsa-only%29) built software emulators for a network music player and its interface; I decided to put together this project.
Here is a video of the completed player:
This project shows how to both build the hardware and set up a Raspberry Pi with the correct software. The parts required may vary based on what kind of a system you want; but here I use a Raspberry Pi Model B and a Mimo UM-720F USB Touchscreen Display (http://www.mimomonitors.com/products/mimo-720-f-flex-screen-mountable-touchscreen-usb-monitor). In addition, I've used a Rosewill powered USB hub to power both the Raspberry Pi and the monitor, and a T-amp amplifier to power a pair of JBL in-ceiling speakers.
The project consists of two main parts. First, prepare the Raspberry Pi to run the appropriate software to connect to the music server and display the interface; and second, install the hardware in the wall.
Image Files Available for pi1 and pi2
For those who don't want to build their own system up from scratch, I have created a disk image of a working system. You can download the compressed image from here. You may select the image for the Raspberry Pi 1 or the Raspberry Pi 2. Unzip the file and write it to a SD card (2GB or larger should work).
You will need to change the root password (currently "root" and the squeezeuser password (currently "squeeze"). You will also need to copy the appropriate xorg config file to /etc/X11/xorg.conf.d/20-displaylink.conf. There are two examples in the /home/squeezeuser/ directory. One is for the Mimo screen used in this project and the other is for the Lilliput 7" UM-70/C/T MiniUSB Touch Screen Monitor. As delivered, the image uses the Lilliput xorg file. Finally, you will need to calibrate your touchscreen by uncommenting the xinpu_calibrator line in the .xinitrc file in the squeezeuser's home directory. The output will be in a text file and you should copy this information into /etc/X11/xorg.conf.d/90-calibrator.conf.
Step 1: Install and Setup Arch Linux
Install Arch Linux First, acquire the Raspberry Pi flavor of Arch Linux from here: http://downloads.raspberrypi.org/arch_latest
Prepare your media and copy the image file to your media as provided in the Raspberry Pi instructions here: http://elinux.org/RPi_Easy_SD_Card_Setup. There is a lot of good information on setting up Arch available through the Arch Wiki at http://wiki.archlinux.org, but a good place to start is the Arch Beginner's Guide available here: http://wiki.archlinux.org/index.php/Beginners%27_Guide. I've included the essential steps below.
I've assumed the following, that the non-root username is "squeezeuser", and that this user has sudo rights.
First, set your location by opening up the list of locales:
# nano /etc/locale.gen
un-comment the appropriate locale for your country (e.g., en_US.UTF-8 UTF-8)
then generate the local information with:
Determine your timezone by finding the appropriate file in the timezone directory:
# ls /usr/share/zoneinfo/
# ls /usr/share/zoneinfo/America
Create a symbolic link to /etc/localtime
# ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
Establish a hostname for your Pi:
# echo squeezeboxPi > /etc/hostname
Set up a non-root user. Ensure that it is given permission for the audio hardware.
# useradd -m -g users -G audio -s /bin/bash squeezeuser
Set a password for this user.
# passwd squeezeuser
Setup autologin of squeezeuer by following this guide: http://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
Optional but highly recommended
Give sudo rights to non-root user by editing the sudoers file. Additional information can be found here: http://wiki.archlinux.org/index.php/Sudo
# EDITOR=nano visudoadd the line:
squeezeuser ALL=(ALL) ALL
# pacman -Syu
Reboot and login as non-root user:
**NOTE: From here on out, I will assume that you are logged in as the non-root user and that user has sudo rights. If your non-root user does not have sudo rights, simply use the su command to escalate your privileges where appropriate. Also note that building files from the Arch User Repository (AUR) often assumes that the user has sudo rights.**
Step 2: Audio and Video Setup
Install needed files for audio and video (and a few others)
$ sudo pacman -S alsa-utils xorg-server xorg-server-utils xorg-xinit xf86-video-fbdev xorg-twm xorg-xclock xterm sudo mlocate openboxAudio should work out of the box. If it does not, make sure that your user (in the examples here, "squeezeuser") is part of the "audio" group. If not, add them with:
$ sudo usermod -aG audio squeezeuser
Also make sure that your PCM audio is not muted and that the volume is up:
And test that you have sound coming out
$ speaker-test -c 2If none of that works, make sure that the appropriate module has been loaded:
$ lsmod | grep sndYou should see snd_bcm2835 as part of the output. If not try:
$ sudo modprobe snd_bcm2835And then test again to see if the audio device has been loaded. If not, I recommend you post to the RaspberryPi Forum
Establish xorg config file for Mimo screen.
I've created an xorg config file that works for me. You can download it from here: 20-displaylink.conf
I've also placed a copy below. You may need to adjust the lines for the framebuffer device ("fbdev") and for the touchscreen. You can see what framebuffer devices you have by issuing the command:
$ ls /dev/fb*And you can similarly see the touchscreen name with:
$ ls /dev/input/by-id/Here is what my xorg config file looks like:
################ DisplayLink Stuff ################### Section "Device" Identifier "DisplayLinkDevice" Driver "fbdev" BusID "USB" # needed to use multiple DisplayLink devices Option "fbdev" "/dev/fb1" # change to whatever device you want to use Option "ShadowFB" "off" # Option "rotate" "CCW" # uncomment for rotation EndSection Section "Monitor" Identifier "DisplayLinkMonitor" EndSection Section "Screen" Identifier "DisplayLinkScreen" Device "DisplayLinkDevice" Monitor "DisplayLinkMonitor" # DefaultDepth 16 EndSection ####################### TOUCHSCREEN #################### Section "InputDevice" Identifier "touchscreen" Driver "evdev" # Option "Device" "/dev/input/event3" Option "Device" "/dev/input/by-id/usb-e2i_Technology__Inc._USB_Touchpanel_L000000000-event-if00 Option "DeviceName" "touchscreen" Option "ReportingMode" "Raw" Option "SendCoreEvents" "On" Option "Calibrate" "1" Option "InvertY" "true" # Option "InvertX" "true" # Option "MinX" "630" # Option "MinY" "31000" # Option "MaxX" "31700" # Option "MaxY" "1000" EndSection Section "ServerLayout" Identifier "default" Screen 0 "DisplayLinkScreen" 0 0 InputDevice "touchscreen" "CorePointer" EndSection
Step 3: Install Squeezelite and Jivelite
The Arch User Repository (AUR) is a great resource. The process is very simple. After setting up an appropriate environment, you download a tarball of source+scripts, untar it, then use "makepkg" to build a package that can be installed by pacman. Makepkg will handle grabbing dependencies if needed.
$ sudo pacman -S --needed base-devel
$ sudo pacman -S git wget
$ cd ~
$ mkdir builds
$ cd builds
Get squeezelite source and build AUR package
$ tar -xvzf squeezelite-git.tar.gz
$ cd squeezelite-git
$ makepkg -s
List the package built (it will look something like squeezelite-git-0.r78.gae7f3e0-1-armv6h.pkg.tar.xz)
$ ls *.tar.xz
Install the package using pacman
$ sudo pacman -U squeezelite-git-0.r78.gae7f3e0-1-armv6h.pkg.tar.xz
Download and edit the systemd service file. A copy is available here
You will need to edit the file to include the name of your non-root user, the MAC address of you Raspberry Pi and the name you want to give your player (optional).
You can determine the MAC address of your Raspberry Pi by issuing the following command:
$ ip link
You should look for something like "eth0", or "wlan0" if you are using a wireless adapter. The MAC address will be in the form of xx:xx:xx:xx:xx:xx and will use hexidecimal.
################################################### # file located at /lib/systemd/system/squeezelite.service # use "systemctl enable squeezelite.service to load # based on a template from RPMFusion and R.G. Newbury from this thread: # <a href="http://www.gossamer-threads.com/lists/mythtv/users/516650?search_string=mythbackend.service%20;#516650" rel="nofollow"> <a href="http://www.gossamer-threads.com/lists/mythtv/user..." rel="nofollow"> http://www.gossamer-threads.com/lists/mythtv/user...</a>> #Usage: ./squeezelite [options]  # Connect to server server at given IP address, otherwise uses autodiscovery # -o Specify output device, default "default" # -l List output devices # -a: Specify ALSA buffer_time (ms) and period_count, default 20:4 # -b : Specify internal Stream and Output buffer sizes in Kbytes # -c , Restrict codecs those specified, otherwise loads all available codecs; known codecs: flac,pcm,mp3,ogg,aac # -d = Set logging level, logs: all|slimproto|stream|decode|output, level: info|debug|sdebug # -f Write debug to logfile # -m Set mac address, format: ab:cd:ef:12:34:56 # -n Set the player name # -r Max sample rate for output device, enables output device to be off when squeezelite is started # -z Daemonize # -t License terms [Unit] Description=Squeezelite Daemon Requires=network.target sound.target After=network.target sound.target [Service] Type=simple # NOTE: using the "squeezeuser" user, NOT root. User=squeezeuser ## note use your mac address as given by ifconfig and the name you wish to give your player ExecStart=/usr/bin/squeezelite -m [xx:xx:xx:xx:xx:xx] -a 80 -n "Pi Player" [Install] WantedBy=multi-user.targetNote: if you get popping or other sound distortion, alter the squeezelite command line by upping the figure after "-a" to 160.
Get source for jivelite and install packages needed to build
Jivelite is the GUI frontend for the squeezelite player.
$ cd ~
$ cd build
$ git clone https://code.google.com/p/jivelite/>
$ cd jivelite
NOTE: earlier versions of this instructable included instructions to download a patch file so that make would look for several header files in locations appropriate for Arch Linux. Triode has altered the Jivelite code so that the patch is no longer needed and the next few instructions are obsolete. The instruction is maintained below for completeness. You do not need to download and patch the code.
The source files for Jivelite assume a Debian-type environment where include files are located in the path of /usr/local/include.
Because Arch uses the Redhat format, we need to patch the files so that the location of the lua.h file (and a few others) is adjusted to follow the Arch conventions. I have made a patch file that should work against the latest source and it can be downloaded here with the command:
$ wget <a href="https://raw.github.com/ggalt/RaspberryArch/master/fix_lua_includes.patch" rel="nofollow"> https://raw.github.com/ggalt/RaspberryArch/master...>
Patch the git repository by first checking the patch:
$ git apply --check fix_lua_includes.patch
Then apply the patch:
$ git am --signoff fix_lua_includes.patch(NOTE: you could issue “git apply fix_lua_includes.patch”, but using “git am --signoff” documents your application of the patch in case you later want to modify your branch).
NOTE: end of obsolete section
Before compiling, add the libraries needed by jivelite:
$ sudo pacman -S luajit sdl sdl_image sdl_ttf sdl_gfxMake the jivelite binary using the PREFIX define we inserted with the patch file:
$ make PREFIX=/usrJivelite should now be in a "bin" file in the directory where you built jivelite.
Create .xinitrc file to start X
To start openbox and the jivelite client, you will need to prepare an .xinitrc file that establishes your environment. An example of what I used can be found at my github page. You will need to make sure that the last line is correct for your path to the jivelite binary file.
Make the .xinitrc file executable.
$ chmod +x .xinitrc
Modify Openbox Configuration
Openbox relies upon a simple XML configuration file. For our touchscreen we don't want to show any of the standard window decorations that a normal window manager shows so we need to make a slight edit to this file.
First create a directory in the squeezeuser's home director call ".config". Please NOTE the "." before the word "config" and make sure it is there. This will make this directory a hidden directory and it is where Openbox will look for the configuration file. Next, make a subdirectory within the ".config" directory entitled "openbox".
$ mkdir .config $ mkdir .config/openbox
Next, copy the standard Openbox configuration file into this directory.
$ cp /etc/xdg/openbox/rc.xml ~/.config/openbox/
Finally edit the rc.xml file to add the following lines near the bottom:
$ nano ~/.config/openbox/rc.xml
<!-- match all windows and remove their decorations --> <application class="*"> <decor>no</decor> </application>
This should be inserted just before the end of the document right after the lines that read:
# end of the example<br>-->
And right before the very end of the document, which ends with:
so the full end of the document should be:
<br># end of the example<br>--><br> <!-- match all windows and remove their decorations --><br> <application class="*"><br> <decor>no</decor><br> </application><br></applications><br></openbox config><br>
Step 4: Prepare the Cabinet
Layout the Location of Parts
Even though the cabinet seems roomy, make sure you have room for everything in there and that there isn't going to be a problem with airflow. The parts that ended up in my cabinet include the Raspberry Pi, a Lepai amplifier, a Rosewill 7-port powered USB hub, a small box to hold the 120-volt power connection and wall warts for both the USB hub and the amplifier. You can quickly run out of space, so carefully consider placement and test, test test!!
Once you have laid out the placement of the parts, drill and tap holes so you can attach the various parts. The amp I chose had convenient mounting holes as did the case for the Raspberry Pi. Always make sure to clean and debur your holes and ensure that any metal shavings are removed from the interior of the case.
I also drilled a set of holes on the side of the circuit breaker cabinet so it could be attached to the stud in the wall.
The amp and the powered USB hub both require full line voltage (120 AC in the US), so pull power from a nearby socket or wall switch. Make sure to follow your local code to attach the wires properly. Install a small box so that you can put in a 2-socket outlet.
Installation squence is important here. Since I was mounting the little Mimo screen on the wall outside of the circuit breaker cabinet, I needed to make sure that the USB cable was pulled through the wall and the screen was mounted BEFORE the circuit breaker cabinet was attached to the wall. Because the mount points for the Mimo screen pull the screen tight to the wall, the sequence I used was:
- Locate and drill holes for the Mimo screen
- Pull the USB cable through the wall
- Plug the USB cable into the Mimo screen
- Mount the Mimo screen on the wall using the appropriately sized screws and washers
- Position the circuit breaker cabinet near the opening
- Pull the USB cable into the circuit breaker cabinet
- Pull the speaker cables into the circuit breaker cabinet
- Pull the Ethernet cable into the circuit breaker cabinet
- Pull the line-voltage power cable into the circuit breaker cabinet and attach per code (I used Romex cable and standard screw-down compression attachments).
- Insert the circuit breaker cabinet in the wall and attach to stud.
Once you have the circuit breaker cabinet in the wall, you can mount all of your parts and start running cables.
Step 5: Finishing Up
During the construction of the room in which the player was being installed, I had run speakerwire and an Ethernet cable to the location where the circuit breaker cabinet was located. After the room was finished, I cut holes in the ceiling to insert the in-ceiling speakers. I used these JBL speakers that were reasonably priced and good quality (don't pay the price listed on the JBL site, they are much cheaper elsewhere).
Test you speaker connections before you insert the speakers in the ceiling. They will come back out if you work at it, but it can be difficult.
Once you have everything working, close up the circuit breaker cabinet. In my circuit breaker cabinet, the front plate contains small breakouts for each circuit breaker. If you need to get access to the interior of the cabinet to adjust the volume or to otherwise work with the other parts, you would not be able to reach through any of the holes. Instead, I cut out the portion of the plate (behind the door) that holds the circuit breakers. This gives a reasonable sized opening so you can easily access the interior of the circuit breaker cabinet. Make sure you clean up your cuts and debur the opening.
I hope you enjoy this project.