This tutorial will guide you through all the steps necessary to stream Spotifyto your Pi, using Mopidy,Mopidy-Spotify, and theIris web interface. The endresult will be a streaming Spotify box that you can control remotely fromanother computer in your house or from your phone (Android or iOS) or tablet.
We've put together a neat little one-line-installer to make this whole processreally easy, but we'll also explain what it does later, because you wouldn'tbe learning otherwise, huh?
Sudo vim /etc/systemd/system/spotify-connect.service Unit Description=Spotify Connect After=network-online.target Service Type=idle User=osmc ExecStart=/home/osmc/librespot -name Raspberry -cache /tmp -bitrate 320 -backend alsa -device hw:0 /dev/null 2&1 & Restart=always RestartSec=10 StartLimitInterval=30 StartLimitBurst=20 Install. 夜な夜なRaspberry Pi Zero WH搭載のVoice Kit V2で遊ぶ日々。今日はこいつでSpotifyを再生しようと思う。 必要なもの Raspberry Pi + スピーカー Spotifyアプリ(PC・スマホなど) Spotifyプレミアム会員. Preparation for the Raspberry Pi Spotify Player. First, a simple Spotify account is required (Free or Premium, it is irrelevant). If you don’t have one, you have to create it first. Then we activate the developer account on the following page: https://developer.spotify.com/my-applications/#!/applications.
For Spotify Connect we look to the Spotify app. The RPi’s secondary weakness is its sound quality. The onboard analogue output is inferior to both the Sonos Connect and the Google Chromecast Audio. One quick fix is to add an external USB DAC. Alas, on all but the Model 4, the RPi shares its USB data bus with Ethernet. Audible dropouts are common. The Raspberry Pi has been very popular as a streaming music player. To connect to the Spotify service he uses the Mopidy. It sounds great and leaves the USB ports free for other things.
It will work either with the built-in 3.5mm stereo jack on your Pi model B+, 2,or 3, or with our audio boards -pHAT BEAT,pHAT DAC, orSpeaker pHAT. It'salso perfect for thePirate Radio Kit,turning it into a neat little streaming audio box.
Note that you'll need a Spotify Premiumaccount for this, although you can use this setup to play local music files,like MP3s, as well.
We recommend using the very latest version of Raspbian Lite, and you'll needan internet connection to install the Mopidy packages later (we'll explain howto do that in Raspbian Lite below). We'd recommend using either the NOOBSinstaller, which you can find here(ensure that you select Raspbian Stretch Lite when installing), ordownloading Stretch Lite from hereand then using the Etcher tool to burn the image to yourSD card.
Currently, our spotipy installer is best supported by Stretch Lite, and maynot work properly in the full version of Raspbian. Because Stretch Lite is..liter (sic) it should also run a bit more snappily than the full Raspbian.
Using the Pi's built-in 3.5mm stereo jack
If you're using the built-in audio on your Pi model B+, 2, or 3, then there's noother preparation needed.
Using pHAT DAC
If you're using our pHAT DAC board, then you need to solder the 2x20 pin femaleheader (that comes with it) to your pHAT DAC (and also solder a 2x20 pin maleheader to your Pi Zero or Pi Zero W, if you're using one). We have a guide onhow to solder headers to pHATs here.
Pop the pHAT DAC onto your Pi's GPIO pins.
Using pHAT BEAT or the Pirate Radio Kit
If you're using the Pirate Radio Kit and haven't already built it, then followour guide hereto learn how to put it all together.
If you're just using pHAT BEAT, then make sure that you've soldered the 2x20 pinfemale header to it. Again, you can follow ourguide to solderingpHATs. Connect a couple of speakers (or just one) to your pHAT BEAT's push fitspeaker terminals.
Pop the pHAT BEAT onto your Pi's GPIO pins, if you haven't already.
Using Speaker pHAT
If you're using Speaker pHAT, then follow our guide to soldering ithere.
Pop the Speaker pHAT onto your Pi's GPIO pins.
Running the installer
Just to reiterate, you'll need an internet connection to run this installer.Pop the SD card into your Pi, make sure that the audio board that you're usingis attached to your Pi (on its GPIO pins) if you're using one, and then plug inthe power and boot up your Pi. Because you're using Stretch Lite, your Pi willboot straight to a terminal, but don't be scared!
You'll need to connect to Wi-Fi. Spotify free vs premium 2016. To do this, you need to edit a file called
wpa_supplicant.conf
. Type the following:Use the arrow keys to move to the bottom of the file, and add the following,replacing the parts that say 'YOURSSID' and 'YOURPASSWORD' with theSSID and password for the Wi-Fi network to which you'd like to connect.
Once you've made those changes, press
control
and x
, then y
, and thenenter
to save and close the file.Now, type
sudo reboot
and press enter
to reboot. Your Pi should now beconnected to Wi-Fi.To run the installer, type the following:
You'll need you Spotify username and password handy for this part. The installerwill ask you to enter your username and password and will use this to configurethe Mopidy-Spotify plugin. Note that your username and password will be storedin plain text so it's a good idea, for safety's sake, to have a unique password(i.e. to make sure it isn't the same as any other passwords that you use), andthat you don't have any open, insecure ports on your local area network.
The installer will prompt you several times, and you should type
y
for all ofthese, with the exception of the device selection. When it prompts you to selecta device, then type the number of the device that you'd like to install. Notethat if you're using the built-in audio through the 3.5mm jack then you shouldselect option 0 here.The installer should also ask if you'd like to reboot once the installation iscomplete. If it doesn't, then restart by typing
sudo reboot
again.What the installer does
If you're not concerned with what the installer does, then stop reading thissection now! If you are, then read on! It's good to know exactly what it does incase you want to pull down our installer script and modify it for your ownpurposes (which you're very welcome to do!)
Our installer installs Mopidy, and a bunch of plugins to add functionality toit. Mopidy is a network music server, that allows you to stream music over yourlocal network or, in this case, from internet music sources like Spotify.
Here, we're using Spotify as our music source, so we're installing theMopidy-Spotify plugin, which allows you to play songs, albums, playlists, andyour own saved music on Spotify.
The Mopidy-ALSAMixer plugin allows you to control the system volume levelstraight from Mopidy, and will also allow us to hook it into our physicalbuttons on pHAT BEAT (if you're using it). https://yellowfirst273.weebly.com/blog/podcast-app-spotify. Spotify free premium cracked.
The physical buttons on pHAT-BEAT are hooked up straight to the GPIO on your Pi.There's a handy Mopidy plugin called Mopidy-TTSGPIO that lets you assignfunctions to buttons connected to GPIO pins; functions like play/pause, forward,back, volume up and down, and shutdown. Fortunately, the buttons on pHAT BEATand the front panel on Pirate Radio are labelled up with those exact functions!
As well as allowing the use of GPIO-linked buttons, this plugin also allowstext-to-speech to announce track and playlist names, and to confirm buttonpresses, amongst other things, although we don't enable this as part of theinstaller script.
The Iris web front-end provides a really slick-looking interface to controlyour Pi running Mopidy. It caters specifically for Spotify, so it's set upwith menu options for playlists and latest releases, etc. If you're not usingSpotify and instead are using local music, then it might be best to look intoone of the other Mopidy web front-ends.
Our installer will also install and configure the software for your chosenmusic output device, be it pHAT DAC, pHAT BEAT, Speaker pHAT, or just the Pi'sbuilt-in audio.
As we mentioned previously, the installer adds your Spotify credentials to theMopidy configuration file (
/etc/mopidy/mopidy.conf
). It also enables theappropriate plugins mentioned earlier, sets up the correct functions for thebuttons on pHAT BEAT (if you're using it), and makes the Pi's IP addressvisible on your local area network, so that you can control it remotely on yourPC/Mac/phone/tablet via the web front-end.Lastly, it runs Mopidy as a system service, meaning that it will fire everythingup automatically when your Pi boots.
Booting for the first time, and using Mopidy
As we said, now that everything is installed and set up, Mopidy should fireitself up when your Pi boots. If your Pi rebooted after the installer ran, thenMopidy may well be running already! It takes a couple of minutes to fireeverything up, and maybe a little longer on a Pi Zero or Pi Zero W, so onceyou've plugged the power into your Pi, or rebooted it, then wait for a fewminutes before following the steps below.
You'll need to know your Pi's IP address to access the web front-end remotely.If you have a display and keyboard attached to your Pi (we'll assume you do,since you ran the installer), then type
ifconfig
in the terminal to find yourIP address. If this is the only Raspberry Pi on your network, and you haven'tchanged the hostname of your Pi, then you will be able to useraspberrypi.local
instead of the IP address.Open a browser window on your PC/Mac/phone/tablet and enter the following URL:
where
192.168.0.2
is the IP address of your Pi, or if you're going to useraspberrypi.local
then enter:Your browser should have loaded up the Iris web interface. It's fairly self-explanatory to navigate, but one important thing you'll have to do is to goto the settings page and log in to Spotify, to authorise it, if it's the firsttime you're using it.
Click 'log in', and it should pop up a new window to authorise Spotify. If itdoesn't, then you might need to switch off any pop-up blockers that might beactive. Now that you've authorised Spotify, you should have access to yourplaylists, and saved albums and artists, featured Spotify playlists, and more.
Because Iris is responsive, it looks really good on mobile as well, resizing andchanging context to work on smaller displays. And because it's just a regularweb front-end it will work equally well in iOS or Android.
With the Mopidy-TTSGPIO installed and active, you should be able to use thebuttons along the side of pHAT BEAT to control your music. Try them!
Taking it further
Why not try some of the Mopidy webfront-ends, or some of theother plugins to use serviceslike Google Play Music, SoundCloud, TuneIn radio, and YouTube. Or try to add anOLED display to showtrack and artist information? You could try to make your Pi music player Twitteror Slack controlled, turning it into a collaborative music player!
Update 2019/12/31: Incorporated some fixes for Raspbian Buster.
With all the “new” developments in home audio, our stereo Hi-Fi set looks quite dated. However, it is hard to beat in sound quality and value for money. Because it’s equipment from the mid-90s it obviously lacks a lot of convenience; flipping records and changing CD’s does get old.
Raspberry Pi Music Player
To streamline this I’ve been looking at streaming solutions using a Raspberry Pi. The easiest solution is to use Bluetooth A2DP to stream directly to the pi. This can be achieved with pulseaudio and should work pretty reliably. It has one big disadvantage: every sound will be streamed, including notification tones. I find this to be very annoying and funnily it seems to be a big focal point for Sonos marketing. Anyway, Bluetooth wasn’t the solution for me.
Mopidy is another possibility. It’s a python based media player that supports all sorts of sources; local files, Soundcloud, Spotify and a lot more. It sports a host of plugins and UI possibilities. However, even with a great web UI like Spotmop/Iris, it still isn’t as user friendly as Spotify.
Raspberry Pi Spotify Player
Finally I ran into raspotify. It uses librespot to implement Spotify Connect functionality. Basically Spotify scans the network for compatible devices and lists these in the client. A device can be selected in the bottom right corner of the spotify application.
Spotify Connect Free Raspberry Pi Download
Raspotify doesn’t have to be linked to a specific account: it can be used by any Spotify Premium user on the (WiFi) network. If you download tweakbox can you get spotify. However, a username and password can be entered in the configuration, the connect client can then also be selected when not connected to the same network.
The best thing about this is that the music is truly played by the pi, if the Spotify client on your laptop or phone is closed it will continue to play. This also means it can be controlled by all devices linked to the spotify account playing, for instance: start by selecting a song on your laptop, close it and skip songs on your phone.
Requirements are very basic, I’m using a Pi 3, but this is probably already overkill. System load is very low when playing songs, so I guess a Pi zero will not be an issue either. The integrated WiFi of the pi 3 is definitely a plus, and more than fast enough for audio streaming.
The required storage space is low too: Raspbian lite and raspotify take up 1.2GB, a 2GB micro-sd card wil do.
One thing to keep in mind is that the analog output of the Pi sucks, either use a digital output (Built in S/PDIF or HDMI output) or get an USB sound card. I’m using a Creative X-Fi Go Pro USB, simply because it was what I had on hand. There are plenty of cheaper options, for instance this one by adafruit. Another option is to use a HiFiBerry Shield, but this is a bit more expensive ($20-$35 depending on the version), though the Specs do look quite good.
Summarized, my setup:
- 8GB Micro-SD Card
- Adafruit blue case and lid
Raspbian Setup
To get started, all the standard tricks for setting up a new Raspbian install:
- Download the latest version of raspbian lite.
- Use etcher and this guide to copy the image to the SD card.
- Create an empty file called ssh on the root directory SD card to enable the SSH client
- Configure your wlan settings by creating a wpa_supplicant.conf file on the root directory of the SD card. Adjust the parameters country, ssid and psk:
- Plug the SD card in the PI and power it on, the steps above have preconfigured the network settings and it is now accessible using ssh.
- Connect to the pi by using your favorite ssh client; putty does the work for me.
- Install some requirements, add the raspotify SSH key, add the apt repository and install raspotify:
Configuration
Now configure raspotify by editing the daemon’s config file. I like to change the name to spotipi (as this just sounds way better!) and increase the bitrate to 320kbps. Other options can be found here.
raspotify should now be running, check it’s status by typing systemctl status raspotify
Setting the USB-Sound card as Default
If you’re using an USB sound card, the next step is to configure alsa to use it as the default. Raspbian adds an index of -2 to the snd-usb-audio module. This results in the integrated audio to be chosen over any other card. This can be resolved by manually configuring the usb card as the default output, however there’s an easier solution: Comment the line setting the index.
With the introduction of Raspbian Buster, the bcm2835_audio module needs to be blacklisted as well.
Reboot the Pi for the modules to reload.
“Setting Up” Spotify
No additional configuration is required on the spotify clients. Simply open the desktop application and look for the devices icon on the bottom right corner. Click it and select the spotipi.
The mobile app will show “Devices Available” on the bottom of the playback screen.
Sources :