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.
Radio streams
Section titled “Radio streams”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
CORS error troubleshooting
Section titled “CORS error troubleshooting”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
Section titled “Azuracast”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
Section titled “Icecast”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.
Using a Playlist
Section titled “Using a Playlist”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=3Version=2File1=http://music-web-server/rock/artist1/song1.mp3Title1=Song 1 - Artist 1Length1=240File2=http://music-web-server/rock/artist1/song2.mp3Title2=Song 2 - Artist 1Length2=300File3=http://music-web-server/rock/artist2/song1.mp3Title3=Song 1 - Artist 2Length3=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
Using relative paths
Section titled “Using relative paths”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=3Version=2File1=rock/artist1/song1.mp3Title1=Song 1 - Artist 1Length1=240File2=rock/artist2/bonus.mp3Title2=Bonus Track - Artist 2Length2=300File3=pop/artist3/single.flacTitle3=Single - Artist 3Length3=180