On this repo you will find a basic example showing how you can run librespot on the steamlink.
What you will find on this repo is just the result of some experiments I made to get something that fitted my own needs concerning spotify and the steamlink. It might not necessarily fit yours. I am just sharing this code in case some people happen to have the same exact needs as me, or are looking after some technical information about how you can pipe the librespot audio backend to another process.
As such, note that:
- The code is really not optimised nor modular. You might have to refactor it to fit your needs.
- I may try to improve it in the future, mainly to add some configuration variables, or maybe to add some features like displaying the current track and so... But please note that I only do this on my free time, so this might come late (if ever), and for now I do not intend to offer much support for what I posted. As I said earlier, this is just an experiment I made for myself, and I just thought it might be useful to others if I shared it here :)
- Using librespot to connect to Spotify's API is probably forbidden by them. Use at your own risk.
- This example is based on the open source unofficial spotify client librespot. You will have to get it and build it prior to using this app. Although I give some tips about the cross-compilation parameters I used, if you need support for building you need to address your issues to them directly.
- librespot requires a Premium Spotify account.
- This app needs the steamlink SDK to build. Download it and get familiar with it first.
This code allows to build an app that you can install and run on your steamlink. Once it is installed, you can launch it directly from the steamlink home menu. This app starts librespot as a background program, and pipes the audio to the first audio device it finds. You juste have to use spotify connect (from your phone or a computer, using the official Spotify application) to start a song. Once you're done, you can exit the app by pressing any key on your keyboard or any buttons on your gamepad (should be compatible whith the Steam gamepad).
Be aware that this is all the app does for now! Since the latest version, the librespot logs are displayed, allowing you to know which track is being played. But still, there is no complex GUI with album cover or so, it's basically just a headless player with a very simple interface.
Follow librespot cross compiling instructions provided on their wiki.
The target architecture arm-unknown-linux-gnueabihf
is compatible with the steamlink.
Before you use the docker image to build librespot, you need to apply the patch described here. This will enable the discovery feature, allowing you to launch librespot without having to provide your Spotify account credentials.
Once that mDNS is patched, build the docker image as suggested:
docker build -t librespot-cross -f contrib/Dockerfile .
Then, use this line to build for the correct architecture:
docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features
The sources of this app are meant to be placed in the examples
folder of the steamlink sdk.
They contain a build_steamlink.sh
script that takes care of the cross compilation for you.
You need to paste the librespot binaries you juste compiled in the librespot-org-build
folder of this repo.
Then you can now launch
./build_steamlink.sh
If the build succeeds, it should generate this file in your current directory:
steamlink/apps/spotify4steamlink.tgz
Now we are going to install spotify4steamlink on the steamlink.
Copy the steamlink
folder that was created during the build step to a USB flash drive.
Insert it into the Steam Link and power cycle the device.
After the reboot, you should see a nice Spotify icon next to your computer(s)! :) Start the app, and you're ready to play some Spotify tunes directly from your steamlink!
By default the app is configured to redirect librespot logs into this file:
/tmp/spotify.log
If you have trouble using spotify4steamlink, you should start by having a look at this file ;).
You might also encounter troubles when exiting the app. For now, the only workaround is to unplug the steamlink, and then plug it back again. Still, during my tests, I noticed the problem seems not to happen if you exit while playing a song. Hopefully having this knowledge will prevent you troubles :).
- plietar for the original librespot project
- The librespot-org team, for their great work and maintenance of the current implementation
- The steamlink sdk which, although not enough documented for my taste, still offers a good start to enhance you steamlink device
- This example on how to play audio with SDL