Use config for title instead of icecast host

main
Jerry Aldrich 5 years ago
parent a7c673eaa0
commit b9541e7ffc
  1. 18
      player.html

@ -120,8 +120,9 @@
var configXMLHTTP = new XMLHttpRequest(); var configXMLHTTP = new XMLHttpRequest();
configXMLHTTP.onreadystatechange = function() { configXMLHTTP.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText); CONFIG_DATA = JSON.parse(this.responseText);
loadStreamChoices(data) renderStreamInfo()
loadStreamChoices(CONFIG_DATA)
} }
}; };
configXMLHTTP.open("GET", "/config.json", true); configXMLHTTP.open("GET", "/config.json", true);
@ -211,21 +212,26 @@
statusXMLHTTP.onreadystatechange = function() { statusXMLHTTP.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
var streamData = JSON.parse(this.responseText); var streamData = JSON.parse(this.responseText);
title = streamData["icestats"]["host"]
songName = fetchText(streamData, "title") songName = fetchText(streamData, "title")
listeners = fetchText(streamData, "listeners") listeners = fetchText(streamData, "listeners")
streamURL = fetchText(streamData, "streamurl") streamURL = fetchText(streamData, "streamurl")
renderStreamInfo(title, songName, listeners, streamURL) renderStreamInfo(songName, listeners, streamURL)
} }
}; };
statusXMLHTTP.open("GET", "/status-json.xsl", true); statusXMLHTTP.open("GET", "/status-json.xsl", true);
statusXMLHTTP.send(); statusXMLHTTP.send();
} }
function renderStreamInfo(title="", songName="", listeners="", streamURL="") { function renderStreamInfo(songName="", listeners="", streamURL="") {
width = 60 width = 60
titleLine = buildTitleLine(width, title) // Use an empty title while config.json is being loaded
if (typeof CONFIG_DATA !== 'undefined') {
titleLine = buildTitleLine(width, CONFIG_DATA["title"])
} else {
titleLine = buildTitleLine(width, "")
}
songNameLine = buildLine(width, songName, " Song Title: ") songNameLine = buildLine(width, songName, " Song Title: ")
listenersLine = buildLine(width, listeners, " Listeners: ") listenersLine = buildLine(width, listeners, " Listeners: ")
downloadLine = buildDownloadLine(width, streamURL) downloadLine = buildDownloadLine(width, streamURL)

Loading…
Cancel
Save