diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/js/radio_emulator.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/client/js/radio_emulator.js b/client/js/radio_emulator.js index 6855fe7..17691d2 100644 --- a/client/js/radio_emulator.js +++ b/client/js/radio_emulator.js @@ -117,7 +117,7 @@ function FetchJSON( url, callback, params ) request.send(); } -function FetchAudio(url) +function FetchAudio(url, callback) { const request = new XMLHttpRequest(); request.responseType = 'blob'; @@ -126,7 +126,8 @@ function FetchAudio(url) debugLog("Got it... trying!") placeholders.dlProgress.value = 100; audioElement.src = URL.createObjectURL(request.response); - audioElement.play(); + callback(); + // audioElement.play(); debugLog("Tried... did it work?"); } else { debugLog(`ERROR ${request.status} while loading ${url}`); @@ -179,14 +180,15 @@ function loadShowCallback(json, params) placeholders.playProgress.max = Math.floor(element.duration/1000); placeholders.showInfo.innerText = JSON.stringify(json, null, 2); audioElement.load(); - FetchAudio(`${audioRequest}${json.hash}`); + FetchAudio(`${audioRequest}${json.hash}`, sync_radio); audioElement.type = json.mimetype; placeholders.currentTime.innerText = Math.floor((now_on_sequence - element.starts_on)/1000); audioElement.addEventListener('ended', function(){ + placeholders.currentTime.value = 0; FetchJSON(`${listRequest}`, hashCallback, [ new Date().getTime() ]); - setTimeout(sync_radio, 10000); + // setTimeout(sync_radio, 10000); }); - setTimeout(sync_radio, 10000); + // setTimeout(sync_radio, 10000); } function slowIncreaseVolume() |