-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
22 lines (21 loc) · 907 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// parse icecast metadata
function parseMetadata() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// change mountpoint variable to match your mountpoint in icecast
mountpoint = "/yourmountpoint";
displaytitle = "display-title";
var response = JSON.parse(this.responseText);
var metadata = response[1].source[mountpoint][displaytitle];
document.getElementById("metadata").innerHTML = "Currently Playing " + metadata;
}
};
// PUT YOUR ICECAST JSON URL HERE
// ONLY WORKS FOR ICECAST 2.5.0+
// icecast 2.5.0 and above: https://yourdomain:port/admin/publicstats.json
xhttp.open("GET", "https://example.com:8443/admin/publicstats.json", true);
xhttp.send();
}
// parse icecast metadata every 10 seconds
setInterval(parseMetadata, 10000);