Metadata

Live Streaming Metadata

Radio Mast provides live metadata updates for streams on the Radio Mast Streaming Network, which can be integrated into your website or custom player widget to display live track metadata to your listeners.

The live metadata is available via HTML5 Server-Sent Events, which can be read in JavaScript using an EventSource object.

The following example JavaScript code shows how to receive Now Playing metadata and prints it to the console:

document.addEventListener("DOMContentLoaded", function() {

    var stream_url = "https://streams.radiomast.io/9fc0077d-ab22-4f8b-b249-94f4bc65996b"; //Insert your stream URL here.

    try {
        var url = stream_url + "/metadata";
        var eventSource = new EventSource(url);

        eventSource.onmessage = function(event) {
            var metadata = JSON.parse(event.data);
            var artistTitle = metadata['metadata'];

            //Print the new metadata to the console.
            console.log(artistTitle);
        }
    } catch (error) {
        console.log("EventSource initialization failed");
        console.log(error);
    }
});