Play your local library, Spotify and even AirPlay via Teddycloud

:small_orange_diamond: Intro :small_orange_diamond:

Since Teddycloud can play radio streams, I’d highly recommend a very nice open source software named OwnTone (formerly forked-daapd). I’ve been using it for more than 10 years.

OwnTone is a media server that lets you play audio sources such as local files, Spotify, pipe input or internet radio to AirPlay 1 and 2 receivers, Chromecast receivers, etc. Or you can listen to your music via any client that supports mp3 streaming.

You control the server via a web interface, Apple Remote, an Android remote (e.g. Retune), an MPD client, json API or DACP. OwnTone runs on low power devices like the Raspberry Pi.

:small_orange_diamond: Killer Feature :small_orange_diamond:

What makes OwnTone a perfect fit for the Teddycloud is that it has a built-in radio stream ouput! So no matter where the input comes from (local, Spotify, AirPlay etc.), everything will be transmitted to http://[OWNTONE-IP]:3689/stream.mp3. You don’t have to setup anything like an icecast server, no need to configure complicated mpd config files etc. It just works!

So out of the box, just by running OwnTone (e.g. as a Docker container), you can assign its output stream to a Tonie of your choice and then you can change dynamically in OwnTone’s web interface what this Tonie is playing. Switch between different radio stations, your personal music library, Spotify etc.

:small_orange_diamond: Extensions :small_orange_diamond:

Shairport-Sync

There’s another fince peace of software named Shairport-Sync. It turns every device into an AirPlay destination! Meaning you can send any audio from your iOS/macOS (even Android) device via AirPlay to your Shairport host. And Shairport can write this stream e.g. into a Unix pipe (FIFO). One feature of OwnTone is that it automatically starts playing a pipe as soon as somebody writes to it. So both of them work perfect together. So here’s a possible chain:
iPhone → AirPlays to Shairplay → outputs to pipe → read by OwnTone → outputs to radio stream → received by Teddycloud → outputs to Toniebox.

This sounds way more “complicated” than it is. :slight_smile: It offers endless possibilities, as you can play basically everything your mobile phone can play (YouTube, Amazon Music, Podcasts, and many more).

Spocon / Librespot

Besides OwnTone’s native Spotify integration or AirPlay, there is also the possibility to install Librespot or Spocon (recommended) on your Pi. This way, you have native Spotify Connect support. Spocon can output to a pipe as well and OwnTone listens on this and starts playing it automatically (same as with Shairport).

:small_orange_diamond: Installation :small_orange_diamond:

All of the tools above can be installed either native or via Docker. You can run them on the same machine, for example a Raspberry Pi. Here’s a detailed setup guide for OwnTone and Shairport (Home Assistant parts can be ignored).

:small_orange_diamond: One more thing :small_orange_diamond:

OwnTone has a nice RESTful API which offers lots of possibilities for automations, remote controls (e.g. via Siri Shortcuts, Scripts) etc. Example: trigger Siri Shortcut with NFC (or voice) which shuffles a random episode of “Die drei ???” on Spotify and play it on OwnTone.

2 Likes

Thank you for sharing this with the community!

Don’t forget, that teddyCloud provides the rtnl data of the box via mqtt, which includes the clapping and the tilting of the box.

This way you could get a step further by using the events to control OwnTone

This is great! I’m having troubles setting this up in a docker container besides my teddycloud (running on a pi4). Any chance you could perhaps write a quick tutorial/yaml file for setting this up?

You can find the docker run command in the ReadMe of the official container:

There is also a docker-compose file if you prefer that:

Be aware that you have to mount three folders: etc, media and cache. Make sure they exist. The media folder is the most important one (where your music library and playlists are located).

2 Likes

Thanks for this, I had to try it :smiley:
But it seems instable at some points.
I used AirPlay in my try.

It takes some seconds until changes for example the volume on the iPhone are played back.
I think this comes from buffering on Shairport → ownTone → Tonybox.

When I change the radio station the pipe stops playing which causes the Tonybox to speak an error to check for the internet connection.
After this it’s not so easy to resume the playback, I think this is a general issue with radiostations and the Toniebox.
→ Is it possible to configure ownTone to play silence instead of stopping the stream?

Sometimes an old buffer is replayed for many seconds when the connection was lost an I got the Toniebox to reconnect.

Hi Xento,

unfortunately all of your complaints are Toniebox/teddyCloud-related.

Every live/radio stream which you are playing on the Toniebox has to be encoded in real-time by teddyCloud. So there is at least a delay with the length of the buffer (default: 2 seconds). If you set the buffer too low, the stream might interrupt and the Toniebox will quit playing the stream immediately.

Not that I know of, sorry.

This is also true for “native” radio stations within teddyCloud. There is a cache for each live stream.

Hi, for everyone using Lyrion Media Server formerly known as Logitech Media Server I managed to create a squeezelite player in a docker container. Its output is piped to ices2 which then sends its output to icecast2.

I created a special tonie so that the toniebox will tune into the icecast stream. As LMS is supporting spotify connect I can listen to spotify and to all the other content available in LMS. So Airplay is available too and basically anything you can play on LMS.

What I haven’t done so far is creating Home Assistant Automations for certain content which should be played from spotify. But this should work too.

The key was this thread https://forums.slimdevices.com/forum/user-forums/3rd-party-software/109522-pipe-squeezelite-to-icecast/page2

and the command to launch squeezelite to pipe content to ices2
squeezelite -o - -n toniebox -a 16 -s LMS_SERVER_IP | ices2 /usr/local/app/ices-conf.xml

Squeezelite and ices2 can be installed in a debian docker container simply with apt-get. And so is icecast.

Let me know if you are interested and you need more information.

Hello dear community,

Unfortunately I’m having trouble installing OwnTone on the Raspi.

When I try to install OwnTone as a docker container via ssh I get the following error message.

Anyone got any ideas?

thanks and regards

There seems to be no docker container for your cpu architecture.

I would propose to use the Owntone container of linuxserver.io anyways.

You can run it e.g. like this (adapt the paths):

docker run -d --name=daapd --net=host -e PUID=1000 -e PGID=1000 -e TZ=Etc/UTC -v /home/pi/owntone/config:/config   -v /home/pi/music:/music   --restart unless-stopped   lscr.io/linuxserver/daapd:latest

Here are basic instructions how to set up shairport-sync on a Pi. Once started, it shows up as an AirPlay (2) target on clients in your network (iPhones, iPads, Macs etc.) and can receive music from those clients. Shairport will then output both the received music and its metadata to pipes and Owntone will automatically read from these pipes (default behaviour). Owntone itself can output all of its content to a web radio stream and this will be played by the Toniebox.

  1. create pipes for shairport music and metadata:
mkdir -p /home/pi/music
cd /home/pi/music
mkfifo airpipe
mkfifo airpipe.metadata
  1. create shairport-sync.conf on host:
mkdir -p /home/pi/shairport
cd /home/pi/shairport
vi shairport-sync.conf

The shairport-sync.conf file has to include the following parameters:

general =
{
    name = "PiAir"; // frei wählbar, Name des AirPort Ziels
    output_backend = "pipe";
    ignore_volume_control = "yes"; // optional - falls yes, immer volle Lautstärke vom Client device
};
pipe =
{
	name = "/mnt/music/airpipe";
};
metadata =
{
	enabled = "yes";
	include_cover_art = "yes";
	pipe_name = "/mnt/music/airpipe.metadata";
	pipe_timeout = 5000; 
};
  1. start shairport-sync container
docker run -d \ 
--restart unless-stopped \ 
--net host \ 
--name=shairport \
--device /dev/snd \
-v /home/pi/music:/mnt/music \ 
-v /home/pi/shairport/shairport-sync.conf:/etc/shairport-sync.conf \ 
mikebrady/shairport-sync:latest
  1. create owntone conf folders on host:
mkdir -p /home/pi/owntone/config
mkdir -p /home/pi/owntone/config/dbase_and_logs
  1. start owntone:
docker run -d \
  --name=daapd \
  --net=host \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Etc/UTC \
  -v /home/pi/owntone/config:/config \
  -v /home/pi/music:/music \
  --restart unless-stopped \
  lscr.io/linuxserver/daapd:latest

Thank you for your feedback. Unfortunately the problem remains.

it means you have 32bit userland. Likely because of a default pi install which later upgraded to 64bit.

docker version will likely say armhf

The appropriate thing to do is format and install 64bit raspberry pi os.

Another solution would be to not use Docker for Owntone but install it via apt:
https://forums.raspberrypi.com/viewtopic.php?t=49928

Thanks Marco!

Unfortunately I wanted to get this to work on a Raspberry 2 and I can’t install a 64-bit system on it.

Is direct installation even possible then?

Should work on a Pi2. But be aware that if you use the radio ouput feature, there is basically a constant ffmpeg job running in the background. So I wouldn‘t recommend to install other things on the same Pi2 such as Teddycloud.

As an addition, here’s how to run Spotify Connect on the same machine.

We just need to create an additional fifo pipe and use this for Spotify.

cd /home/pi/music
mkfifo spotpipe

The rest is basically the same as with shairport-sync. We mount the folder with the pipe into the librespot container and tell it to use the pipe as audio output for music.

Here’s a docker-compose.yml. The DEVICE_NAME is how this target is named in your Spotify app.

services:
  librespot:
    image: giof71/librespot:latest
    network_mode: host
    environment:
      - BACKEND=pipe
      - DEVICE=/mnt/music/spotpipe
      - BITRATE=320
      - INITIAL_VOLUME=100
      - DEVICE_NAME=Teddify
    volumes:
      - /home/pi/music:/mnt/music

Preview in Spotidy app: