Linking with Spotify via Pi MusicBox

Linking with Spotify via Pi MusicBox

This article was translated to English, and was originally published for deviceplus.jp.

This time, we’ll be playing around with “Pi MusicBox!”

“Pi MusicBox” allows users to link up to any music streaming service easily while also being able to play back music files. This article will go over all the setup steps, from installing to linking up with “Spotify.”

Pi MusicBox

Fig. 1

Pi MusicBox (Official Site)

This is the official site for “Pi MusicBox.”

“Pi MusicBox” is based on an extensible music server written in Python called “Mopidy.” Music playback is possible with any music files (MP3/FLAC/AAC) on the same network or local file, while linkups are possible with the following music services.

  • Spotify
  • SoundCloud
  • Google Play Music
  • Podcasts
  • Internet radio (TuneIn, Dirble, AudioAddict, Soma FM)
  • Subsonic

Installing Pi MusicBox

Fig. 2

In the middle of the page, under the “Download” headline, there’s a link for GitHub.

Release v0.7.0 Release Candidate 5 · pimusicbox/pimusicbox · GitHub

As of January 2018, the latest version is “v0.7.0 Release Candidate 5” (2017-07-28 Release)

Let’s download the ZIP file from “musicbox_v0.7.0RC5.zip.”

Here you can find an SD card image to use on your Pi. It’s around 300MB to download and will fit on a 1GB or larger SD card.
The file size for the download will be 300MB, with an SD card with more than 1GB required for installation. (An 8GB SD card was used for this article).
Start by using Win32 Disk Imager, overwrite the file onto the SD card, and then set it to Raspberry Pi and turn on the power. When doing this, use a cable to connect directly to the internet. (If you only have a Wi-Fi setup, we’ll talk about that later)

Fig. 3

Connecting to the display directly will produce this screen. It’s the familiar Raspbian loading screen. The second time loading this screen felt like it took a little bit more time than the first. When it’s done loading, you’ll be able to access “http://musicbox.local/” from the same network terminal!


Fig. 4

This is the initial display screen when connecting via a PIC. The green and bluish gray combination felt similar to Volumio.

The main menu will have the following eight items. Including the icon, each initiative feels pretty easy to understand.

  • Now Playing
  • Queue
  • Playlists
  • Browse
  • Streams
  • Search
  • Setting
  • System

Other than that, there’s only “Fullscreen” on the sidebar.

Fig. 5

This is just after we connected to a smartphone. Because it uses a responsive design, aside from the part layout, it’s roughly the same screen as the PC version.

It’s possible to access the same URL on an iPhone. Since it seems like you can’t access via Android, let’s try accessing through an IP.

Fig. 6

Clicking on the upper-left hamburger icon will display the side menu. Simultaneously, you can open and close the PC version.

Fig. 7

Selecting “Fullscreen” on the smartphone will display the message seen in Fig. 7.

Just as the display says, “Add on home screen” and starting up the icon you made will allow you to use this like an app on all screens (When using iPhones).

Linking with Spotify

Linking to music streaming services on “Pi MusicBox” is a standard feature.

This time, let’s try linking to “Spotify.”

*A Spotify Premium account was used for this article.

Fig. 8

Fig. 8 displays all the music streaming services that are possible for linkup on the “Settings” screen. Clicking on this will open up the settings menu and display the input columns for toggling ON/OFF, entering account info if needed, etc.

Fig. 9

Fig. 9 is the setup for “Spotify.”

The very top is the ON/OFF switch. Clicking ON will bring up the “Search” bar. “Spotify” is toggled as OFF by default (By the way, I usually have “YouTube,” “Podcasts,” “TuneIn,” “Dirble,” and “Local Files” toggled ON by default).

Enter your Spotify account info in “Username” and “Password.”

There are other items as well, but we’ll just be inputting the info to use music playback on “Spotify.”

After you’re finished inputting the info, click on the “Save” button at the very bottom of the screen to save the info.

Since you need to restart the program to update the info, click on the “Apply changes now” button and restart Raspberry Pi.

(Going back to the “Home” link at the bottom left won’t display that much, so it’s probably better to re-access via “http://music.local”)

Fig. 10

Let’s try searching with “raspberry” on the “Search” screen.

The top select box only searches results on “Spotify.” (*It seems like using the free version won’t display any search results)

About Local Files

Music playback on music files saved onto Raspberry Pi is of course possible.

Because “samba” is pre-installed in the package on “Pi MusicBox,” you can access the file right away.

Fig. 11

A computer named “MUSICBOX.LOCAL” will be displayed for a PC connected on the same network. Music files will be stored on a shared directory called “Music” on this computer.

Music files will be stored on a shared directory called “Music” on this computer.

Setup for Wi-Fi

A direct internet connection is recommended from the beginning, but for places that only have Wi-Fi as an option, being able to use this right away would be very convenient.

Thinking that, I quickly looked up and came upon this answer listed on the last portion of “Instructions” on the official site.

ConfigurationYou can edit all settings in the new settings page from the webclient. To access it, you need a network connection. To enable Wifi, you can either first connect the Pi using a cable and use the settings page, or fill in the wifi-settings in the ini file on the SD Card. For that:

  1. You can edit all settings in the new settings page from the webclient. To access it, you need a network connection. To enable Wifi, you can either first connect the Pi using a cable and use the settings page, or fill in the wifi-settings in the ini file on the SD Card. For that:
  2. Put the SD-card into your computer. Open the contents of the ‘config’ folder of SD-Card in your Finder/Explorer.
  3. Add your Wifi network and password to the file (and edit other settings if you want) settings.ini It has instructions on what to put where.
  4. MusicBox will autodetect usb audiocards/speakers/boxes and hdmi. It’s possible to override this in the settings. For example if you want to use analog out while having hdmi connected.

For using Wi-Fi, there are two options: “How to set up from the browser via accessing through a wired connection” and “How to set up Wi-Fi on the SD card’s ini file.”

setup wi-fi connection
Fig. 12

For the first method, “How to set up from the browser via accessing through a wired connection,” it describes how to directly register info onto the “Network” on the “Settings” screen. Input your password under “Wifi Password” on the SSID for “Wifi Network Name” and click the “Save” button. This setting will be effective after restarting.

One other method is “How to set up Wi-Fi on the SD card’s ini file.”

Temporarily remove the SD card from Raspberry Pi and edit the ini file via Windows or on another machine.

list of files on SD card
Fig. 13

Fig. 13 displays the list of files on the SD card. The file we’ll be editing is in the “config” folder.

open settings.ini in text editor
Fig. 14

The corresponding file is “settings.ini.” Let’s open this file in text editor.

/config/setting.ini

On my side, I found 12-22 nearby lines related to network setup.

On the 18th line of SSID on “wifi_network,” I input the password for the 19th line’s “wifi_password.” You can turn off the auto detect for the speakers this way, but I think that setting up through the browser after connecting is simpler.

After overwriting the file and saving, return the SD card to Raspberry Pi.

After restarting, you’ll be able to access through 「http://musicbox.local/」!

Setting up the Speakers

Same as with setting up the Wi-Fi, we’ll list how to set up the speakers.

Configuration

  1. MusicBox will autodetect usb audiocards/speakers/boxes and hdmi. It’s possible to override this in the settings. For example if you want to use analog out while having hdmi connected.
Fig. 15

Opening the third item (Audio) on top of “Settings” will bring up the “Audio output” item where you can set up the output. “Automatic” is toggled on by default, but when connected to a display via HDMI, the display speakers will be prioritized. If you want to always use earphone jacks, select “Analog.”

Finally, click the “Save” button to save these settings. These settings will go into effect after restarting.

Inputting Commands

Fig. 16

Fig. 16 is what will be displayed after restarting “Pi MusicBox.” Because Raspbian is the base, you can log in and turn on the command function.

Since it’s not auto login, an ID and password are needed.

Fig. 17

On the top page of the Official Site!

You can log in with “root” as the ID and “musicbox” for the password. Since there’s no desktop, it’ll only be the command prompt.

In Conclusion

Differences with other music servers and “Pi MusicBox” will vary depending on the link-up with other music streaming services. Since the input column for accounts is already set up, the process is pretty simple! You’ll now be able to link up to any paid service and casually listen to tons of music!