Skip to content

Playing Background Audio

Background audio can be added to any channel by using the backgroundAudio property in the channel’s configuration:

channels:
- number: 1
color: blue # some example content
backgroundAudio: placeholders/bgm-3.mp3

In the example above we’re playing a single MP3 file from the placeholders directory:

  • index.html
  • config.tvs.yml
  • Directoryplaceholders
    • bgm-3.mp3

This property is defined on the channel, not the channel’s content, and will apply to the entire channel. You can only have one background audio track per channel.

To add more dynamic content, you can use internet radio streams as background audio. You can either link to a public radio stream or host your own using a program like Azuracast or Icecast.

channels:
- number: 2
channel-list: true # whatever channel content you want
backgroundAudio: http://radio.plaza.one/mp3
backgroundAudioOptions:
description: Plaza.one radio

Shoutout to Nightwave Plaza who has graciously allowed us to use their radio stream in TVS! Check them out and support them!

Breaking down what’s happening here, we’re linking directly to the stream itself, not an M3U8 or PLS file. The stream loads without any CORS errors because the server is configured to allow cross-origin requests.

The backgroundAudioOptions block has a description field where you can title the audio you’re playing. This description will be shown in the info OSD (press i i on the keyboard to toggle this).

CORS error screenshot

Access-Control-Allow-Origin: * is a the key to avoiding CORS errors. This header tells the browser that it’s okay to load this resource from a different origin (hostname).

Azuracast is what I’d recommend for making your own radio stations. Not only is it capable of hands-off 24/7 broadcasting, but it also provides an easy way to get information about what’s playing which TVS can display. To do this, install Azuracast and set up a station. An easy way to get going is to turn on auto DJ using Liquidsoap, add music files and assign them to the default playlist and make sure that “Public Pages” are turned on. Suppose the mount point for your station is /radio.mp3, your configuration might look like this:

channels:
- number: 3
channel-list: true # whatever channel content you want
backgroundAudio: http://my-azuracast-instance/listen/[station_name]/radio.mp3
backgroundAudioOptions:
description: My Azuracast stream
nowPlayingUrl: http://my-azuracast-instance/api/nowplaying_static/[station_name].json
nowPlayingProvider: azuracast

Icecast is used by default in Azuracast but can be used on its own for a lighter-weight solution, though you’ll need to roll your own broadcasting client. I won’t get into the specifics of how to set a server up, but suppose you’ve got a single mount point (/stream.mp3) and an Icecast server running. Your config might look like this:

channels:
- number: 4
channel-list: true # whatever channel content you want
backgroundAudio: http://my-icecast-instance/stream.mp3
backgroundAudioOptions:
description: My Icecast stream
nowPlayingUrl: http://my-icecast-instance/status-json.xsl
nowPlayingProvider: icecast

status-json.xsl is a file that lets you get information about what’s playing in Icecast; this is what TVS reads to display the current track information.

You can also use a PLS playlist as your background audio source. This is a more advanced setup as the playlist needs to resolve to audio files that are accessible over a web server.

Consider this example file:

[playlist]
NumberOfEntries=3
Version=2
File1=http://music-web-server/rock/artist1/song1.mp3
Title1=Song 1 - Artist 1
Length1=240
File2=http://music-web-server/rock/artist1/song2.mp3
Title2=Song 2 - Artist 1
Length2=300
File3=http://music-web-server/rock/artist2/song1.mp3
Title3=Song 1 - Artist 2
Length3=180

This will create a playlist with three songs, each with its own metadata (title and length). Make sure the audio files are accessible over the web and that the URLs are correct. You can then host this playlist file anywhere accessible to TVS over the network and use it as your background audio source:

channels:
- number: 5
color: red # whatever channel content you want
backgroundAudio: content/playlist.pls
backgroundAudioOptions:
description: My PLS playlist
  • index.html
  • config.tvs.yml
  • Directorycontent
    • playlist.pls

Your playlist can use relative paths, but must be relative to the PLS file’s location. Consider this setup on http://music-web-server/:

  • playlist.pls
  • Directoryrock
    • Directoryartist1
      • song1.mp3
      • song2.mp3
    • Directoryartist2
      • song1.ogg
      • bonus.ogg
  • Directorypop
    • Directoryartist3
      • single.flac

Your playlist.pls file might look like this:

[playlist]
NumberOfEntries=3
Version=2
File1=rock/artist1/song1.mp3
Title1=Song 1 - Artist 1
Length1=240
File2=rock/artist2/bonus.mp3
Title2=Bonus Track - Artist 2
Length2=300
File3=pop/artist3/single.flac
Title3=Single - Artist 3
Length3=180