You will likely want to customize the metadata of your stream to change in various ways, be it
the currently playing DJ or song or something else.
For files in backup playlists, the metadata is read directly from the files. The best thing to do is to have your files tagged properly. If you want to change the metadata in some other way it is possible.
Annotate protocol in playlist file
If you are using a playlist file, a simple way to change the metadata of the files is to add some annotations to the playlist file using the annotate protocol.
The rewrite_metadata is a way to replace certain metadata keys with others.
I think the idea behind using this is maybe you would want to replace the metadata with custom metadata you have entered with the annotate protocol.
Pattern is two strings "a, b" which will replace the occurence of b with a.
For example pattern could be:
Then you would use the function like this:
This will replace the title metadata with the artist metadata.
There is also an if statement operator, in case the metadata you want to rewrite is blank, the function won’t be called.
Honestly I think map_metadata is a lot easier to use, and if you have simple needs it may be better for you.
Using this syntax you can replace any element of the metadata, title, artist, etc.
To rewrite the metadata in my live stream, I keep track of a ref called title_prefix that I set when my dj authenticates to the stream.
Then I set the metadata with this ref, using map_metadata:
I will discuss dj authentication more in the next chapter.
Strip metadata from Traktor
If your DJs stream with Traktor, you may notice that Traktor automatically inserts the track’s metadata into the stream. If you wish to remove this, its possible. By default, map_metadata updates the metadata with the value returns, and keeps the other metadata you did not specify to update. If you wish to remove the other metadata you did not explicitly specify, just pass the update=false option to map_metadata:
Is the metadata there?
In case you don’t know, you can check the metadata by going to the icecast
status page on localhost:8000.
You want to make sure this parameter is set when calling output.icecast.
Metadata from icecast json/xml
If you are embedding an HTML5 or flash player on your site, you may find it difficult to get the metadata displaying in the player properly. Most HTML5 players don’t seem to read the metadata directly from the stream very well. Icecast provides a JSON endpoint with current metadata and statistics.
Don’t ask why the extension is .xsl when its actually json data, I have no clue. The json support was introduced only recently, and before only XML format was available.
Now just call this function periodically, say every 10 seconds, with setInterval.
Modern Online Radio with Liquidsoap Book - Free Sample
Need more help with liquidsoap?
Can’t get your script to work?
I wrote a book to help you learn Liquidsoap. The book covers all aspects of liquidsoap, from getting started, to making dynamic streams, audio processing, video, customizing metadata, authentication, and more. The book is available for purchase now here!
You can get a free sample chapter of my book! Just enter your email address to subscribe to my mailing list and I'll send you a free PDF sample of the book in return.