Wall Mounted SqueezePlayer with Raspberry Pi
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 visudo
add 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
$ sudo pacman -S alsa-utils xorg-server xorg-server-utils xorg-xinit xf86-video-fbdev xorg-twm xorg-xclock xterm sudo mlocate openbox
Audio 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 2
If none of that works, make sure that the appropriate module has been loaded:
$ lsmod | grep snd
You should see snd_bcm2835 as part of the output. If not try:
$ sudo modprobe snd_bcm2835
And 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.target
Note: 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_gfx
Make the jivelite binary using the PREFIX define we inserted with the patch file:
$ make PREFIX=/usr
Jivelite 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>
For more detail: Wall Mounted SqueezePlayer with Raspberry Pi