Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Mar 2017

    Spotify Connect on LMS - Proof of concept

    I've searched the web for a solution to use my Squeezeboxes as targets for Spotify Connect, but just come out empty handed. So, if you want something properly done, you have to do it yourself. :-)

    As a first step, I created a proof of concept using librespot and vlc. This turned out to work quite well, so I thought I should share what I did. Note that this require a fair level of technical expertise. See this as inspiration, rather than a failure-proof step-by-step recipe (despite the format :-)).

    I hope someone can help me pick this up to turn it into a proper plugin.

    Anyway, here's the instructions.

    1. Install rust

    Follow the instructions on [rustup.rs](CENSORED). This is
    typically: `curl CENSORED -sSf | sh`

    2. Install librespot

    Follow the instructions on [github](CENSORED).
    This is typically: `git clone CENSORED`
    followed by `cargo build --release`, if you have all dependencies installed
    (portaudio and buildtools).

    3. Install vlc

    On Ubuntu, `sudo apt install vlc`.

    4. Try it out

    Collect some raw audio data from librespot: `target/release/librespot --name
    Squeezebox --cache /tmp/librespot --backend pipe > /tmp/raw.dat`

    Run this command, use another Spotify client to connect to "Squeezebox" and
    play a song for like 10 seconds. Then exit the command with Ctrl-C. Verify
    that you have a (fairly large) file `/tmp/raw.dat`.

    Try converting the raw data to mp3 using vlc: `cvlc --demux=rawaud
    --rawaud-channels 2 --rawaud-samplerate 44100 /tmp/raw.dat
    :sout='#transcode{vcodec=none,acodec=mp3,ab=320,ch annels=2,samplerate=44100}:std{access=file,mux=raw ,dst=/tmp/vlc.mp3}'
    :no-sout-rtp-sap :no-sout-standard-sap`

    Verify that `/tmp/vlc.mp3` plays as an correct mp3 file.

    5. Build a streaming pipeline

    Connect librespot with vlc streaming: `target/release/librespot --name
    SqueezeBox --cache /tmp/librespot --backend pipe | cvlc --demux=rawaud
    --rawaud-channels 2 --rawaud-samplerate 44100 -
    :sout='#transcode{vcodec=none,acodec=mp3,ab=320,ch annels=2,samplerate=44100}:http{dst=:8081/respot.mp3}'
    :no-sout-rtp-sap :no-sout-standard-sap`

    6. Listen in on the Squeezebox

    On your Squeezebox, go to Radio > Tune in URL and enter
    `CENSORED`, where HOSTNAME is the name of the host you're
    running librespot on.

    If all works well, you should now have streaming music from Spotify Connect.

    7. Tie it all together

    You'd probably want to start the librespot + vlc command on boot, and add
    the URL as a bookmark. How to achieve this is left as an excercise to the

    8. Limitations

    You will not get track information or album art, since from the Squeezebox
    point of view you're just playing a single streaming mp3 file. There's a
    clear and noticable lag (~ 5 seconds) from the control on Spotify. This
    solution requires extra CPU power due to the re-encoding of the stream. It
    is probably not very robust, and it is likely that you will need to restart
    the pipeline from time to time. The legal reservations that apply to
    librespot of course also apply to this solution (that is, if this is
    considered a breach of the Spotify ToS or not).

    Consider this a proof of concept. I'd really like to turn this into a proper
    solution with an LMS plugin, but unfortunately I don't have the time to do

    Note that this solution will not replace nor conflict with any current
    solution you have for playing music from Spotify directly on your Squeezebox
    (the official client or the libspotify-based plugin).

    9. Acknowledgements

    I was inspired by [this blog

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    I think your approach isn't totally wrong in its principles. It's just not ready for prime time yet :-). We'd indeed need a wrapper application around librespot, exposing control feature (play, queue, stop etc.) and serving the data in a way we can consume in LMS. That's pretty much what Triode had done for the existing implementation. Quite obviously there should be more than just this, to eg. handle when somebody was controlling it through the Spotify app etc. So... who's familiar with Rust? Or willing and able to learn it?

    http://www.herger.net/slim-plugins - Spotty, MusicArtistInfo

  3. #3
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Magicus - have you made any progress? I was wondering whether we could have a librespot helper application pipe the audio data to LMS' transcoding framework. Are you familiar with Rust?

    http://www.herger.net/slim-plugins - Spotty, MusicArtistInfo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts