diff --git a/player.html b/player.html index 65481e1..a4a7a0c 100644 --- a/player.html +++ b/player.html @@ -120,8 +120,9 @@ var configXMLHTTP = new XMLHttpRequest(); configXMLHTTP.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - var data = JSON.parse(this.responseText); - loadStreamChoices(data) + CONFIG_DATA = JSON.parse(this.responseText); + renderStreamInfo() + loadStreamChoices(CONFIG_DATA) } }; configXMLHTTP.open("GET", "/config.json", true); @@ -211,21 +212,26 @@ statusXMLHTTP.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var streamData = JSON.parse(this.responseText); - title = streamData["icestats"]["host"] songName = fetchText(streamData, "title") listeners = fetchText(streamData, "listeners") streamURL = fetchText(streamData, "streamurl") - renderStreamInfo(title, songName, listeners, streamURL) + renderStreamInfo(songName, listeners, streamURL) } }; statusXMLHTTP.open("GET", "/status-json.xsl", true); statusXMLHTTP.send(); } - function renderStreamInfo(title="", songName="", listeners="", streamURL="") { + function renderStreamInfo(songName="", listeners="", streamURL="") { 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: ") listenersLine = buildLine(width, listeners, " Listeners: ") downloadLine = buildDownloadLine(width, streamURL)