##09/08/2017 Notice: Due to changes in the Spotify-web-app the following howto no longer works.
For a working version of Spotify on your Rpi’s OSMC, see this solution:
09/08/2017 discontinued: Do you wish to play your Spotify music on your Raspberry Pi mediaplayer with Kodi?
Sources: 09/08/2017: discontinued
My personal website: [HowTo] Setup a spotify-connect-web-server on a Raspberry Pi with OSMC – Zatarra's Blog
Nederlandse variant: [HowTo] Installeer een spotify-connect-web-server op een Raspberry Pi met OSMC – Zatarra's Blog
Why would I do this? 09/08/2017: discontinued
As Spotify-premium user you can stream Spotify to your OSMC based Kodi player (through any Android, Windows or Apple device with Spotify installed).
Tested on RPi 3 with OSMC 2016.12-1
Prerequisites: 09/08/2017: discontinued
- A Raspberry Pi (RPi 1, 2 or 3), with OSMC installed
- A Spotify Premium account
- A Spotify key (request this at Spotify: https://developer.spotify.com/technologies/libspotify/application-keys/). You have to fill out a form and just tell them it’s for personal use etc. They’ll send you the key after a few days. Make sure you get the binary version.
- A windows computer (I have no experience with Ubuntu or any Linux OS, but that will probably work as well)
- Audio output = HDMI, analog or HiFiBerry (haven’t been able to successfully use Bluetooth/A2DP)
Steps
'1. As your RPi is turned off, remove de SD-card and copy the Spotify key onto the SD-card. Put the SD-card back in your RPi and boot.
'2. Download Putty for Windows: Download PuTTY: latest release (0.79)
'3. Find out what your RPi’s IP-adress is (in Kodi choose: System; My OSMC, network, wired/wifi)
'4. Open Putty on your windows machine and type in the IP-adress of the RPi and login with:
Username: osmc
Password: osmc
If you have changed your password, use that one.
'5. Install the Spotify connect web server by typing the following lines:
curl -O curl -OL https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.3-alpha/spotify-connect-web.sh
chmod u+x spotify-connect-web.sh
./spotify-connect-web.sh install
'6. [Deleted]
'7. [Deleted]
'8. [Deleted]
'9. Copy the Spotify-key to the right place, by typing:
sudo cp /boot/spotify_appkey.key spotify-connect-web-chroot/usr/src/app/
'10. Your Spotify Server should work. Test it by typing:
./spotify-connect-web.sh -o hw:0 --username [12345678] --password [xyz123] --bitrate 320 --name [any name]
(remove the )
note: if you get an error, device does not exist, try aplay -l
to see what audio devices are available. It could be hw:1
, instead of hw:0
. (the command aplay
is not standard included with OSMC. You need to install alsa-utils for this. Use the following commands for installing alsa-utils: sudo apt-get update
, followed by sudo apt-get alsa-utils
)
'11. If everything is correct, you should be able to find the RPi on any other Spotify App.
Now it’s time to make sure the server is available every time you restart the RPi (autostart). Do this by following the next steps:
'12. reboot the RPi
'13. Repeat step 3 (login with Putty)
'14. Type the following:
sudo nano scs.service
'15. Now you made a new script.
With cabled network connection add the following text in the script:
[Unit]
Description=Spotify Connect
After=network-online.target
[Service]
Type=idle
User=osmc
ExecStart=/home/osmc/spotify-connect-web.sh -o hw:0 --username [12345678] --password [xyz123] --bitrate 320 --name [any name]
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20
[Install]
WantedBy=multi-user.target
With wifi connection add the following text in the script:
[Unit]
Description=Spotify Connect
After=network-online.target
[Service]
Type=idle
User=osmc
ExecStartPre=/bin/sleep 25
ExecStart=/home/osmc/spotify-connect-web.sh -o hw:0 --username [12345678] --password [xyz123] --bitrate 320 --name [any name]
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20
[Install]
WantedBy=multi-user.target
(for wifi connection a 25 second delay is added)
'16. Close the editor and save by typing ctrl-X
'17. select Y
to save
'18. Type the following:
sudo mv ./scs.service /etc/systemd/system/scs.service
sudo chmod a+u /etc/systemd/system/scs.service
sudo systemctl daemon-reload
sudo systemctl enable scs.service
sudo systemctl start scs.service
'19. Close Putty
'20a. If your sound output is HDMI:
In Kodi (on the RPi) choose: System; My OSMC; Pi Config; Display
and make sure the next is selected:
hdmi_force_hotplug
'20b. If your sound output is analog (thanks to Pezzy):
Manually edit the config.txt file by typing in putty:
sudo nano /boot/config.txt
Add this line at the bottom
hdmi_ignore_edid_audio=1
Save and shutdown by typing: ctrl-X
and Y
to save
'20c. If you have an Hifiberry DIGI+:
Hifi-berry works nowadays with this solution. The latest versions of OSMC, as well as the spotify connect, releases the audio devices for the use with other instances. Make sure that:
- OSMC releases the audio device when not in use (found in ‘systems’; ‘system’; ‘audio output’; ‘keep audio device alive’ = ‘off’)
'20d. If you other audiocards/output:
I haven’t tried other audio output, so can’t help you there yet. Maybe someone can add tips in this section for output via jack or additional soundcards. Or it could work out of the box.
Enjoy.
Changelog:
jan 7th 2017
- The link to the download site. It now links to the latest release 0.0.3, like the instructions from Fornoth at Github.
- Works with multiple audio devices (see step 20c)
- In my experience this version of spotify-web (0.0.3) needs to be assigned an audio device. Command -o hw:0 is therefore added.
feb 2nd 2017 - Clarified the use of -aplay at step 10.
- Deleted step 5-9 and replaced is with a simple command to download a spotify-key
feb 26th 2017 - Download link for the spotify key doesn’t work anymore. It can be officially requested at Spotify, but you’ll probably wait a bit before they send it to you. https://developer.spotify.com/technologies/libspotify/application-keys/
sep 8th 2017 - Support for this program has been discontinued. So currently this howto is no longer useful.