From ef8653fec7ece10221e0916dc2002db414505f59 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 14 Oct 2024 05:17:01 +0300 Subject: Improvements --- client/js/radio_emulator.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'client') 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() -- cgit v1.2.3