What is it?¶
Pi MusicBox lets you listen to your music through your HiFi.Supporting Spotify, Google Music, Soundcloud, YouTube, Podcasts, Apple Airplay,UPnP/DLNA, Internet Radio, not to mention your vast mp3 collection. A musicplayer which you can operate from your couch using a tablet, smartphone,notebook or desktop computer.
Connect your Raspberry Pi to your speaker system, install the software and enjoylistening to all your music!
I'm running Ubuntu 16.04 LTS and installed both mopidy and mopidy-spotify from the mopidy repository. When I open ncmpcpp or ncmpc, in the browse window, there is only Top albums Top artists Top tracks Why are my personal spotify playlis. Ncmpcpp - A curses client written in C tailored after ncmpc. Pms - A console client written in Go with vi-like interface. Vimpc - A curses client with vi-like key bindings. Pimpd2 - Feature-packed cli client with interactive shell and regex queries. Nncmpp - A basic curses client that looks like Sonata. Mmtc - A minimal mpd terminal client.
Possibilities¶
Pi MusicBox is designed to be controlled over your home network from anothercomputer, tablet or smartphone. In fact, any device with a modern web browser(Chrome 14+, Safari 6+, Firefox 11+, Internet Explorer 10+) can be your remote.You could also attach a keyboard or buttons for local operation if you wanted.
Connect your speakers directly via line out, HDMI or through an external USB orHAT soundcard. Play music from your SD Card or USB hard drive and useWiFi/ethernet to access music on network shares, internet radio as well as musicfrom a number of supported streaming services. The software will detect as muchof the configuration as possible at startup and configure the system for youautomatically.
Requirements¶
The main requirements are a Raspberry Pi with a ‘good’ 5V power supply, anetwork connection for it and a 1GB or larger SD card. The latest, fasterRaspberry Pis are the best choice but models A, B and B+ will still work. You’llalso need a way to listen using either a HiFi system, headphones (with pre-amp),a set of USB speakers or the speakers on a HDMI television. If you want tolisten to Spotify you will need a Spotify Premium account.
A monitor/television is not necessary but might come in handy if you need totroubleshoot startup problems.
Networking¶
Pi MusicBox is designed to be controlled over your home network and needs tohave a working network connection. If you can use an ethernet cable, you justneed to plug it in and you’re done. Connecting via WiFi using a USB dongle,or the Raspberry Pi 3 / Zero W onboard WiFi, is also possible(see Wifi Network). Most USB WiFi dongles are supported but not all. Ifyou are buying one, make sure it works in Raspbian. You’ll need to enter yourWiFi network details before you start (see Initial Config).
Note How do u get spotify premium on the apple.
If you want to use a static IP address, you need to login and configure thatyourself (see Getting Your Hands Dirty).
Installation¶
Download and unzip the latest “ready to eat” image available hereand use Etcher to easily copy it to your SD Card (more information.The image has been tested on a 1GB SD card but a larger card will leave you withmore free space and is preferable.
Initial Config¶
If using a WiFi connection you must enter your network details in
settings.ini
before you boot the system. You can also set other configoptions at this point but it’s generally a good idea to start with the minimumconfig required when booting for the first time. It’s easy to change otheroptions later via the settings web page once you are up and running.To do this, insert the SD Card into a computer (Windows, Mac, Linux),and open it in the file manager. It will contain a folder called
config
andwithin that will be a file called settings.ini
. The file is structuredas an ini file and should be opened in a text editor. All lines starting with a#
are comments designed to help you and will be ignored by Pi Musicbox.Avoid changing the order or formatting of the non-commented out lines.For details on specifically what WiFi settings you need to set, seeWifi Network.
Booting¶
Insert the SD Card in your Pi and then connect the speaker (turn the volumeright down), network, and power cables. You may also wish to connect amonitor/television to the HDMI connector to follow the boot process but it’s notrequired.
Note
The system will reboot a few times during startup and, depending on whichmodel Raspberry Pi you are using and what initial config you have set, thismay take a few minutes. Please be patient.
Web Interface¶
Once the system is ready for use, the web interface will be available in yourweb browser at one (or more) of the following addresses:
Most modern web browser will require you to explicity enter the
http://
partof the address or the trailing /
as otherwise they will unhelpfully try tosearch the internet for what you’ve typed!Note
Windows computers might require the installation of Apple Bonjour/iTunes formDNS to work correctly.
Note
Linux computers might require the installation of Avahi fir mDNS to workcorrectly.
Warning
Android does not support mDNS and you might have to access your Pi MusicBoxusing it’s IP address rather than it’s hostname. This address is differenton every network but will look something like http://192.168.1.5/ orhttp://10.1.100.2/. You will have to either look it up using a networkutility, find it from your router status page, or just plug in a screen andyou’ll see it displayed after startup. You can also install one of the manymDNS helper apps such as Zentri Discovery.
If, after waiting a few minutes, the web interface is still not responding,there might have been a problem during startup. The easiest thing to do at thispoint is plug in a screen and see the error message displayed. SeeTroubleshooting for more help.
Once your Pi Musicbox is running and accessible on the network, you’ll want tocustomise it and enable some music sources. The easiest way to do this is usingthe Settings web page which you’ll find listed in the navigation menu on theleft side of the main page. Below that you’ll also find a link to the Systempage where you can safely shutdown and restart the system. Avoid just removingthe power cable unless you enjoy SD card corruption.
Web Radio¶
To play streams from radio stations you like, you have to use a so calledstream url. You cannot use container files like M3U, XSPF or PLS (yet), whichare commonly available, you have to add the real stream. This stream url ishidden inside the .M3U or PLS file. To find this url, open the container filein a text editor.
A PLS file looks like this:
The stream url would be:
M3U and XSPF files look different, but the stream url is always clearly visible.
You can find radio stations (PLS and M3U) using services likehttp://dir.xiph.org/ or http://listenlive.eu/ or http://dirble.com/.
Just add the stream url and the name of the station and press the Play button.The last 25 stations are saved locally using a browser cookie (not on theserver yet, so you need to do it on every client you use).
MPD¶
Though the web based interface is recommended, you can also use native softwarewhich support the MPD (Music Player Daemon) protocol to control Pi MusicBox.
Apps and applications are available for all sorts of devices and operatingsystems. Not all of them work great with MusicBox though. For Android, MPDroidis recommended. On OS X, Theremin works (without search). On Linux, you can usethe great working and wonderfully named console app ncmpcpp. On a LinuxDesktop, GMPC and Sonata work well. On iOS, mPod and mPad. For Windows, clientsare either not working great or untested.
More settings¶
A lot of things can be configured on Music Box. Edit the configuration fileaccording to your needs. You have to reboot the Box to see the changes.
Wifi Network¶
If you connect a supported wifi dongle to your Pi, the MusicBox software shouldbe able to detect and use it instead of a cable connection. Most dongles aresupported, but not all. If you buy one, make sure it’s supported by Raspbian,the Linux distribution on which MusicBox is based. To make wifi work, you haveto fill in the network name (SSID) and your password in the config file. Addthese lines to the basic configuration above, or edit the default file suppliedwith MusicBox:
Substitute the
mywifinetwork
and mypassword
with the correct values ofyour own network. For now, the wifi on Pi MusicBox only supports WPA(2)encrypted networks, configured via DHCP. As with a wired network, if you wantto use a static address, WEP encryption or no encryption, you need to get intothe console and configure it yourself (see Getting Your Hands Dirty).Better Quality¶
The Pi can play the music from Spotify in different types of quality. Thebetter the quality, the more data needs to be downloaded from Spotify. It’scalled bitrate. Higher quality means a higher bitrate and a bit more use ofyour internet connection. Typical broadband connections should be able tosupport the highest bitrate easily. If you have a good connection to theinternet, you can set the quality to high, but if your connection is slow orunstable, or you have usage limits on your connection, you can it lower and useless data. Possible rates are 96 (low, but acceptable quality, FM like), 160(default) or 320 (highest quality, CD like).
Set the bitrate to high like this in the configuration file:
Or set the bitrate to low like this:
Sound Configuration¶
By default Pi MusicBox will send the sound to the analog headphone output onthe Pi. This sound is good enough, but due to hardware constraints, not alwaysgreat. If you want to have better sound, use the HDMI to connect the Pi to anamplifier, or connect an USB soundcard (also called USB DAC, Digital AudioConverter), USB speakers or USB headphones. Almost all typesof USB speakers, headphones and DAC’s are supported, but if you buy one, makesure it’s Linux compatible. DAC’s with digital outputs are also available inmany web stores.
When booting, Pi MusicBox will autodetect what is connected to the device andconfigure it accordingly. If you connect multiple devices, USB will be selectedfirst as a sound output, HDMI after that, and lastly the analog output of thePi itself. You can override this in the configuration file using the followingline:
If you include this, the default output will be the analog headphones jack ofthe Pi, even if you connected an USB device or an HDMI cable.
The options are:
analog
, hdmi
, usb
Last FM¶
Another service supported by Pi MusicBox is Last FM. It collects the tracks youplay, so you can discover new music. Go to http://www.last.fm/ to create anaccount if you don’t already have one. To let Last FM collect the tracks youplay, fill in the credentials of this service:
SoundCloud¶
Another service supported by Pi MusicBox is SoundCloud, the service which letsyou “Hear the world’s sounds”. To configure it, you need a special ID, a token.Get this token from http://www.mopidy.com/authenticate/ You have to login withyour SoundCloud id to get the token. This information is not shared with themopidy.com site. When you login, you’ll see a token appear on the page. Addthis token to the ini file like this:
Where you replace the example
1111111111
by your token. Using theSOUNDCLOUD_EXPLORE
configuration, you can configure the playlists you wantto see in the interface.Multi Room Audio¶
Pi MusicBox supports so called Multi Room Audio. You can have multipleRaspberry’s on your network, for example in different rooms. The devices needto have their own names to be accessible. Use this option to give your MusicBoxa different name:
The name you choose should be no longer than 9 characters and only containnormal characters and numbers in the name (no spaces, dots, etc).
After a new boot, the webinterface for playing music will be accessible via anew address. Where the default would be http://musicbox.local from devicesthat support Bojour/Avahi, when you change the name, it becomeshttp://newname.local. In the example above it would be:
It’s not possible to play different music on multiple devices using the sameSpotify account at the same time. This is a limitation of Spotify. If you havemultiple accounts, it of course is possible.
Security¶
Pi MusicBox is not totally secure and not intended to run outside a firewall,only in the cosy environment of your local network. The heart of MusicBox, isnot protected enough to do that. Also, the passwords of Spotify and wifi arestored in plain text on the SD Card. This might be fixed in the future.
For more security, change the default password by setting this line:
where
mypass
is your new password. This will change the passwords of boththe user musicbox
and the user root
. The password will be removed fromthe configuration file after it’s updated.If you want, for more security to change the
root
password to somethingelse, use this line:where
mypass
again is your new password.Playing your own Music Files¶
Though Spotify boasts a library of over 20 million tracks, not all artists andsongs are represented. So it would be nice to be able to play MP3 files for themissing songs, wouldn’t it? Well the good news is that Pi MusicBox supportsplaying local or networked MP3, FLAC or OGG files. The bad news is that it’s atiny bit complicated in the current version (0.4). Also, the songs are noteasily available in the webinterface. They are not in the playlists, you haveto search for them to play them.
Networked Music¶
The easiest way to play your own music files, is via the Windows Network. To dothat, edit the configuration file, so that MusicBox knows where your files are.This address could be a bit cryptic to a first time user. This is an example:
or:
The first part
//
is the way shares in the Windows Network are created.Just add it and forget it. The next part (mynasserver
or 192.168.1.5
)is the name or ip address of the server which hosts the file, and the last part/musicshare
or /shared/music
, tells MusicBox which share to mount.When your server is protected, you need to set the username and password forthe Network share using the following configuration lines:Scan Music¶
MusicBox will not see the files immediately. https://browncontact728.weebly.com/dj-software-spotify-free.html. The music files needs to bescanned at boot, every time you add or remove files. This process can slowdownthe boot of the MusicBox, so use it with care. MusicBox will scan the filesusing the following configuration lines:
or:
Ncmpcpp Mopidy Spotify
The names speak for themselves. Using
SCAN_ONCE
, the music files will onlybe scanned, yes, once. Use this if you don’t change the music files often. UseSCAN_ALWAYS
if you change your music files a lot. This will enable you tochange the files and reboot MusicBox. It will recognize the new files after theboot. But, again, the scanning process can slowdown the booting of MusicBoxconsiderably.Ncmpcpp Spotify
Local Music¶
Pi MusicBox also has an option to store music files on the SD Card. Thisprocess is also a bit more complicated. Since MusicBox is created for a 1GB SDCard, or larger, the file system is also less than 1 GB. If you put MusicBox ona larger SD Card, the rest of the space on the card won’t be used, unless youresize the file system.
You can do this manually, on a computer using a partition manager, or you canlet MusicBox try to resize it automatically. This process is tested, but notguaranteed to work. You could end up with a non working musicbox if the processfails. That’s most of the time no problem, since you can put the originalMusicBox image on the SD Card again and start over. If you did a lot ofcustomization, it’s recommended to backup your card first.
Using this line in the settings, Pi MusicBox will automatically resize thefilesystem to the maximum size of the SD Card:
Put Files on the Card¶
Putting music files on the SD Card is only recommended on cards with a sizelarger than 1GB. MusicBox needs the 1GB for caching and other storage. Afterresizing an SD card with more storage, you can put your own music files on thePi using either the Windows Network, or by mounting the root filesystem of thecard on a Linux computer and copying the files. Leave at least 200MB of freespace on the device.
To use the Windows Network, you have to have the workgroup name of the WindowsNetwork set to the default name,
WORKGROUP
. If you want another name, youhave to change it by hand in the file /etc/samba/smb.conf
(see GettingYour Hands Dirty). Remember to let MusicBox scan the files at boot (see ScanMusic)Getting Your Hands Dirty¶
If you are willing to get your hands ‘dirty’, there are a lot more options toexplore in Pi MusicBox. For this, you have to login to the box on the console,or via SSH. To login remotely via SSH, you will need to enable the SSHservice. Do that by adding this line to your configuration file:
Reboot. After that, you can connect to MusicBox via SSH.
Mopidy¶
The main ingredient of MusicBox is Mopidy, an open source music serverdeveloped by people from all over the world. It can be extended in a number ofways. By default, Pi MusicBox is set up using the best working extensions. Butit can be extended to play music from e.g. SoundCloud, Google Music and BeetsMusic. More extensions are developed as you read.
How to add these extensions is beyond the scope of this document, but a lot ofresources and documentation can be found on http://www.mopidy.com/. Thedevelopers can be reached on the mail list of Mopidy,https://groups.google.com/forum/?fromgroups=#!forum/mopidy, or via IRC Chat onthe #mopidy channel on Freenode.
rc.local¶
Another important piece of Pi MusicBox is the file
/etc/rc.local
. It’sa shell script. This is where the (sound) hardware is setup and theconfiguration is done. For example, the configuration file of Mopidy is createdfrom rc.local
. Edit this file is you want to add, change or removefeatures.Working at Midnight¶
For Linux novices, a nice utility called Midnight Commander could be of use tobrowse the filesystem and edit files. It works like the age old DOS utilityNorton Commander and it’s included in MusicBox. Start it using the command:
Static Network¶
To use MusicBox in a network with static IP addresses, you have to edit thefile
/etc/network/interfaces
.The lines that configure the wired network, look like this:
Ncmpcpp Mopidy
An example file for a static wired network, you should change it to somethinglike this:
Fill in the correct ip addresses for your network.
Updating¶
Mopidy Spotify Ncmpcpp
When a new version of MusicBox is released, the only way to update it, is to doa new installation. You can update the kernel and other packages of the systemmanually, but changes in the files specific for MusicBox will not be updated,so it could eventually break things. Generally it’s not needed to updatethings, but if you really want, you could issue the command:
rpi-update
toget the latest kernel. This will take a while. Another command is apt-getupdate&&apt-getdistupgrade
. These commands take a while to run, so grab acoffee!Fun & Questions¶
Enjoy your new way of listening to music! If you have questions, don’t beafraid to ask them at The mailing list of Mopidy/MusicBox, or via chat.Addresses and instructions are on http://www.pimusicbox.com/.