diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-10-14 05:17:01 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-10-14 05:17:01 +0300 |
commit | ef8653fec7ece10221e0916dc2002db414505f59 (patch) | |
tree | b4a920af63ecccc9163fb0b78ee2eb9c2896ebaa | |
parent | 39c632eda398b5294186b5a3b1d71e9e575f4485 (diff) | |
download | arching-kaos-radio-ef8653fec7ece10221e0916dc2002db414505f59.tar.gz arching-kaos-radio-ef8653fec7ece10221e0916dc2002db414505f59.tar.bz2 arching-kaos-radio-ef8653fec7ece10221e0916dc2002db414505f59.zip |
Improvements
-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() |