INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: HOW TO: Play Streaming Services in MC and stream across zones  (Read 4604 times)

imugli

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1601
HOW TO: Play Streaming Services in MC and stream across zones
« on: February 04, 2017, 02:16:36 am »

I've been racking my brain about this for a bit, and today I sat down and got it to work.

I am currently streaming Spotify, through MC, to a second linked zone.

It certainly isn't PERFECT, but nor is it that hard to do :-)

Here's a rundown, as performed on Ubuntu 16.10 server.

Essentially what we're doing is setting up an Icecast server, routing the output from Spotify to the Icecast server, then playing the stream in MC.

I'm assuming you have MC installed.

1. Install Spotify on your server -

Code: [Select]
sudo apt-add-repository -y "deb http://repository.spotify.com stable non-free" &&
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D2C19886 &&
sudo apt-get update -qq &&
sudo apt-get install spotify-client

Install icecast2 on your server -

Code: [Select]
sudo apt-get install icecast2

Install Darkice on your server -

Code: [Select]
sudo apt-get install darkice

Create a config file darkice.cfg (in any location). Here is an example -
Code: [Select]
[general]
duration        = 0      # duration in s, 0 forever
bufferSecs      = 1      # buffer, in seconds
reconnect       = yes    # reconnect if disconnected

[input]
device          = default # or `pulse' for Pulseaudio
sampleRate      = 44100   # sample rate 11025, 22050 or 44100
bitsPerSample   = 16      # bits
channel         = 2       # 2 = stereo

[icecast2-0]
bitrateMode     = vbr       # variable bit rate (`cbr' constant, `abr' average)
quality         = 1.0       # 1.0 is best quality
format          = mp3       # format. Choose `vorbis' for OGG Vorbis
bitrate         = 256       # bitrate
server          = localhost # or IP
port            = 8000      # port for IceCast2 access
password        = hackme    # source password to the IceCast2 server
mountPoint      = mystream.mp3  # mount point on the IceCast2 server .mp3 or .ogg
name            = mystream

Edit the file as you see fit. I've found MC doesn't like .ogg streams, but that might just be my system or a missing codec on my part.

Start Icecast and Darkice -
Code: [Select]
/etc/init.d/icecast2 start
darkice -c <path to>/darkice.cfg


Now open your volume control. In the Recording tab, you should see Alsa Plug-in [darkice].
Change that to the "Monitor for" device.

Open Spotify and start playing your fave playlist.

You should now be able to open the url <server.ip>:8000/mystream.mp3 in any MC on your network.

But what if you don't want to LISTEN to Spotify on the server?

Pulse lets us create NULL devices. Use the followng command -
Code: [Select]
pactl load-module module-null-sink sink_name=Stream \ sink_properties=device.description="Stream"

Now, in your Volume Control, under playback, you'll see the option to change where Spotify outputs to.
Change it to the "Stream" device.

In the Recording tab, change the device to the "Monitor for Stream" device.

Now Spotify will continue to play in the background, without you hearing it.

Go to MC or a browser and open the same URL as before. You can then link it to another zone. I had it playing between my MacBook Air and Linux computers well enough.

The Spotify app on your phone should pick up that Spotify is playing on your server and let you control it.

Unfortunately there isn't any meta data streamed through DarkIce (or from Spotify for that matter) so the Track name will always display as the name of your stream, but meh.

The best part is that you should be able to use this guide to set up streaming for any web / streaming service.

If you want to stream multiple sources, simply create another .cfg for darkice, create another NULL sound device and repeat the process.

I've tested this running multiple instances of Spotify concurrently on my server and it works no problem. Your system resources are your only limit.


Sources:
http://www.g0hww.net/2013/11/using-null-sinks-with-pulseaudio.html
http://askubuntu.com/questions/28496/how-do-i-setup-an-icecast-server-for-broadcasting-audio-in-my-network
http://howtoubuntu.org/how-to-install-spotify-in-ubuntu

 


mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5175
  • "Linux Merit Badge" Recipient
Re: HOW TO: Play Streaming Services in MC and stream across zones
« Reply #1 on: February 04, 2017, 11:01:29 am »

This is pretty rad.  I actually tried an icecast solution for this at one point but it didn't work very well for me, but I wasn't using dark ice.  I'll have to spin it up again and give it a shot.  Thanks for the config file!
Logged

imugli

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1601
Re: HOW TO: Play Streaming Services in MC and stream across zones
« Reply #2 on: February 04, 2017, 03:36:24 pm »

You're welcome. Glad you got something out of it. This kind of geekery is the reason I love Linux 😊
Pages: [1]   Go Up