This may be common knowledge already but I thought I'd share... I've got
a fairly nicely working (but ugly) hack where I run Spotify on my
laptop, stream the output to Squeezecenter on my media server and then
play via Squeezebox.
Parts needed on the laptop:
- Spotify running on wine
- Icecast 2 (configured so your Squeezecenter can access the
stream)
- Pulseaudio
- GStreamer
Here is the script that runs from the "Spotify stream" menu item:
Code:
--------------------
#!/bin/sh
PA_SINK="spotify"
ICECAST_PASSWORD="XXX"
ICECAST_MOUNT="spotify.ogg"
BIT_RATE="160000" # free spotify is 160k, no need to go higher?
# start a null sink that spotify should play to
PA_MODULE_ID=$(pactl load-module module-null-sink sink_name=$PA_SINK)
# encode spotifys output back to vorbis, send to icecast
gst-launch-0.10 pulsesrc device="$PA_SINK.monitor" ! \
audioconvert ! \
vorbisenc bitrate=$BIT_RATE ! \
oggmux ! \
shout2send ip=localhost \
port=8000 \
password=$ICECAST_PASSWORD \
mount=$ICECAST_MOUNT &
PID=$!
# start spotify
padsp -n Spotify -m spotify-stream \
wine $HOME/.wine/drive_c/Program\ Files/Spotify/spotify.exe
# TODO: should do
# "pactl move-sink-input $PA_STREAM $PA_SINK"
# but I don't know how to get the $PA_STREAM id for the spotify stream...
# WORKAROUND: use pavucontrol to move the playback stream to the Null
# sink (this needs to be done only once).
# remove the sink, stop encoder
pactl unload-module $PA_MODULE_ID
kill $PID
--------------------
If that looks horrible, that's because it is. Spotify decodes vorbis,
pa pushes it to gstreamer that decodes it to vorbis again and gives it
to icecast for streaming to Squeezecenter. At this point you can tune
squeezebox to http://<laptop-ip>:8000/spotify.ogg. As you can imagine
all this transcoding and streaming means a significant (~5 sec) latency
and uses enough cpu to heat the room... Zero playback problems so far
though, so I'm happy with it.
As you can see in the comment in the script, there is an additional
one-time setup step: When Spotify is playing, move the playback stream
to the Null output (arrow button).
I'm pretty sure this is a very ass-backwards way of doing this... If
you know how to do all this without monitoring a null sink or even just
how to get the PA stream id in the script, do reply :)
--
jku
------------------------------------------------------------------------
jku's Profile: http://forums.slimdevices.com/member.php?userid=8144
View this thread: http://forums.slimdevices.com/showthread.php?t=70052
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix