owntone-server
owntone-server copied to clipboard
Spotify Connect
Would be awesome if spotify-connect could be supported so that one could stream from spotify to forked-daapd and then to all the speakers in the house:
https://github.com/plietar/librespot
It's probably possible to do this even now via pipe (the same was as mentioned here: https://github.com/ejurgensen/forked-daapd/issues/278)
See also this discussion: https://github.com/plietar/librespot/issues/88
Certainly would be an interesting feature.
It would mean that a user like me, which has both local music (+ radio) and Spotify, would need to use two clients. Personally, I prefer having all my music controllable from one client per device (mostly Remote on my phone). So what I am going for (and hoping for) is still proper integration. This is hard to do right now because of the lack of replacement for libspotify. So right now, Spotify support in forked-daapd is lackluster. The plan on my part (and @chme, I believe) is to see if Spotify delivers on their promise to make a replacement for libspotify. The announcement says before the end of this year.
Anyone who feels like writing them to encourage this should probably do so!
Yeah one would have to use two clients. (My use case is identical to yours). Not ideal But much better than only having the playlists as we have now. I kinda don't really expect the spotify API to be released anytime soon...
Yes, they may well disappoint. I actually have begun working on a little something that will give you all your Spotify music in forked-daapd. Basically by mixing libspotify with the web api. So I hope they will at least not cripple libspotify any more.
Cool. Let me know if I can help testing. However still think that forked-daapd besides iTunes being the only piece of software able to stream to multiple airplay speakers synchronised would be good to accept input from spotify directly via spotify-connect. also forked-daapd as a airplay target would be nice to distribute audio from e.g. an iPhone to multiple speakers.
Sounds interesting. Let me know if you need someone to test it out...
Sent from my phone.
On 26 Oct 2016, at 20:43, ejurgensen [email protected] wrote:
Yes, they may well disappoint. I actually have begun working on a little something that will give you all your Spotify music in forked-daapd. Basically by mixing libspotify with the web api. So I hope they will at least not cripple libspotify any more.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I agree, it’s just that adding direct support for librespot and libshairport/libshairplay in forked-daapd (and maintaining the support) is a bit more work than I can take on.
I hope that the pipe (+ metadata pipe) can serve the purpose for now. Maybe a good thing to add to the current pipe implementation would be to make forked-daapd automatically start playing a watched pipe, if there is audio being written to it. That would mean you could start playback without interacting with forked-daapd.
So for the interested: I got https://github.com/plietar/librespot to work on the same raspberrypi that runs forked-daapd.
I created a named pipe:
mkfifo ~/music/spotify
and then run librespot like this:
/home/pi/librespot --backend pipe --device /home/pi/music/spotify -n spotifyConnect --cache /tmp > /dev/null 2>&1
then I can "play" Spotify in forked-daapd and select SpotifyConnect in the Spotify App - The output then goes to which-ever speakers selected in forked-daapd.
Not exactly elegant but it works nicely to stream Spotify from the app to all airplay speakers.
This is very cool.
https://bbs.nextthing.co/t/howto-chip-or-chip-pro-as-spotify-connect-radio/17621
I found this guide, is this what you did or?
Thanks
I went for step 2B from your link. I downloaded the binary.
the point however is starting it so that it outputs the audio to a named pipe, which is then read by forked-daapd
This is done as I wrote above.
Ive found a place with the install, but no idea how to install this to a headless Pi Zero
https://github.com/herrernst/librespot/releases
Any guides, im Googling, but im struggling.
Right, hope this helps someone in the future :)
Create the directory first, cd into that and then;
wget` https://github.com/herrernst/librespot/releases/download/v20170717-910974e/librespot-linux-armhf-raspberry_pi.zip
unzip librespot-linux-armhf-raspberry_pi.zip
So if I run it this way, it works, but obviously goes no where; (I have set up the pipe, same as above)
./librespot --name "AirPlay" --username "Username" --password "Password"
If I try running it like this;
./librespot --name "AirPlay" --username "Username" --password "Password" --backend pipe --device /home/pi/music/spotify -n spotifyConnect --cache /tmp > /dev/null 2>&1
It seems to just crash, any ideas?
Ok, so its running now, but the pipe doesnt work;
I can see a device called "AirPlay" I can play to it.
I cant see it in the remote and I can see this in the logs
laudio: Error initializing Pulseaudio: Connection refused
Im also using the native spotify "client" the one that just shows you the playlists in the remote. But I would assume if it was picking up the pipe correctly, it would show both?
Did you create the pipe?
mkfifo /home/pi/music/spotify
and of course this needs to be inside the library folder of forked-daapd
so the above assumes that /home/pi/music/
is the library folder of forked-daapd.
This option in /etc/forked-daapd.conf
is also helpful
...
# Watch named pipes in the library for data and autostart playback when
# there is data to be read. To exclude specific pipes from watching,
# consider using the above _ignore options.
pipe_autostart = true
...
This makes forked-daapd automatically start if it detects data in the pipe. So you do not have to select the pipe file, forked-daapd will automatically do that if it detects that librespot is putting data into it.
so the above assumes that /home/pi/music/ is the library folder of forked-daapd.
Thats what it was, I had the default in the conf file. Thanks so much, would never have got that.
But its all working, and working well, crashes a bit though :( How are you finding stability? Also is there a way to make this run on start up?
Thanks again for your help with this :)
stability is so-so. It is crashing on me always. mostly I suppose it's forked-daapd crashing. not sure why though and I haven't had time to go into debugging.
For running it as a service I use systemd
/etc/systemd/system/spotify-connect.service
pretty crude but it works.
[Unit]
Description=Spotify Connect
After=network-online.target
[Service]
Type=idle
User=pi
ExecStart=/home/pi/librespot --backend pipe --device /home/pi/music/spotify -n spotifyConnect --cache /tmp > /dev/null 2>&1
Restart=always
RestartSec=10
StartLimitInterval=30
StartLimitBurst=20
[Install]
WantedBy=multi-user.target
I can then use sudo service spotify-connect start
Don't like to hear about forked-daapd instability, so now I have also setup librespot with a pipe to test it the next few days...
Would be nice if librespot would support metadata pipes like shairport does. That could also help remove some of the volume control lag.
@snizzleorg sorry, been away, thanks for that.
Have you guys seen this?
https://github.com/dtcooper/raspotify/issues/15#issuecomment-329002310
Its a client that's easy to install and has a conf file for settings, like piping as you can see from this issue.
@1liminal1 @snizzleorg is the one that explained it to me :P
@ejurgensen Just wanted to say thanks for an awesome piece of software. The setup detailed in this thread took me about an hour, which was a lot quicker than I expected. Mostly thanks to your slick software. Getting rid of volume control lag would be brilliant!
@chimpy Nice! and thanks for your help on that other thread :)
I also second how awesome forked-daapd is and just a general thanks for how helpful everyone is in getting stuff setup.
Yes, I'm hoping librespot will implement metadata pipe or file, so forked-daapd can pickup volume changes instantly. However, so far there has been no response in the thread, so might require that someone steps up and makes a PR.
I've been running the setup a few days, and so far no crashes. If there are specific circumstances that produce a crash I hope you will share.
thanks for testing. I have not had time to dig to the root of this. Not sure what the crashes are and who is to blame. It's not so easy to debug and doesn't follow a pattern so that I can recognise so far.
However if I find a little more time I will do some more thorough testing. Maybe I can find some specific circumstances.
I have mine working now as well so ill test over the next few days and let you guys know about stability.
So the meta-pipe causes the slow response, is there any workaround for that, or nothing we can do?
Take a look here, seems to be more Active mantained than librespot for now:
https://github.com/Spotifyd/spotifyd
Thanks for the hint. But isn't it built on top of librespot? Or am I not understanding it properly?
It also looks like it only can output to alsa and Pulseaudio, which won't do for forked-daapd. It will need to provide raw audio so that forked-daapd can send to any output (Airplay, Chromecast, alsa etc.).
Seems to be build around librespot Yes and currently support pipe. It's like raspotify but works also in x86. Anyway: https://developer.spotify.com/web-api/web-api-connect-endpoint-reference/
Yes, the connect api is interesting. The web connect api + librespot could replace libspotify, it seems. However, librespot is written in Rust, and forked-daapd is C. It is possible to call Rust libraries from C, but looking at it I think it would require a wrapper, and I have never done any Rust.
Sorry if I made some stupid mistake, just trying to get to know all this and get it all to work.
The forked-daapd server is up and running perfectly. (Only trying to figure out how to get a simple playlist, but not for now)
What I did so far was:
wget https://github.com/herrernst/librespot/releases/download/v20170717-910974e/librespot-linux-armhf-raspberry_pi.zip
unzip librespot-linux-armhf-raspberry_pi.zip`
mkfifo /data/Music/Spotify
(This is a sub dir of my forked-daapd library)
And in /etc/forked-daapd.conf
I unhashed
pipe_autostart = true
If I run the command below, librespot starts, stays open at the cml, shows info (like loading song etc) and I can see it from my Spotify app. The songs plays, and of course I don't hear anything (I need the pipe)
./librespot --name "AirPlay" --username "username" --password "password"
But if I run the command below, it returns directly to the cmd, and I don't see anything in the Spotify app. I don't know where to find the log of librespot so I can't debug. What am I doing wrong?
./librespot --name "AirPlay" --username "username" --password "password" --backend pipe --device /data/Music/Spotify -n spotifyConnect --cache /tmp > /dev/null 2>&1