From 4f35b67261e2f8401d952dee6b5db58bbf3c7cc5 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 28 Jul 2024 18:31:44 +0300 Subject: Now radio player loops --- src/js/arching-kaos-decentralized-radio.js | 42 +++++++++++++++++++++++++++--- src/js/arching-kaos-modules-mixtapes.js | 2 +- src/js/arching-kaos-tools.js | 1 + 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/js/arching-kaos-decentralized-radio.js b/src/js/arching-kaos-decentralized-radio.js index 7cec5b1..c8b99d1 100644 --- a/src/js/arching-kaos-decentralized-radio.js +++ b/src/js/arching-kaos-decentralized-radio.js @@ -8,10 +8,46 @@ radio.addEventListener("pause", ()=>{ radioButton.innerHTML = ' '; }) -function radioToggle(){ - if (radio.paused) { +var played = []; +var list = mixtapeIds; +var currentPlaying = 0; + + +function radioLoad() +{ + var elem = document.querySelector('#'+mixtapeIds[0]).firstChild.cloneNode(true); + currentPlaying = 0; + radio.appendChild(elem); + radio.play(); +} + +function radioLoadNextAndPlay() +{ + currentPlaying += 1; + radio.removeChild(radio.firstChild); + var elem = document.querySelector('#'+mixtapeIds[currentPlaying]).firstChild.cloneNode(true); + if ( elem !== null ) + { + radio.appendChild(elem); + radio.load(); radio.play(); - } else { + } + else + { + radioLoad(); + } +} + +radio.addEventListener("ended", radioLoadNextAndPlay); + +function radioToggle() +{ + if (radio.paused) + { + radio.play(); + } + else + { radio.pause(); } } diff --git a/src/js/arching-kaos-modules-mixtapes.js b/src/js/arching-kaos-modules-mixtapes.js index f12e2ea..79efe99 100644 --- a/src/js/arching-kaos-modules-mixtapes.js +++ b/src/js/arching-kaos-modules-mixtapes.js @@ -28,7 +28,7 @@ function akModuleMixtapes(zblockIPFSHash, zblockObject, blockObject, json){ source.src = getIPFSURL(json.ipfs); var rs = source.cloneNode(true); audio.appendChild(source); - radio.appendChild(rs); + //radio.appendChild(rs); art.appendChild(audio); audio.addEventListener( "loadedmetadata", ()=>{ if ( mixtapes[zblockIPFSHash] === undefined ){ diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js index 1de38a9..755290c 100644 --- a/src/js/arching-kaos-tools.js +++ b/src/js/arching-kaos-tools.js @@ -157,6 +157,7 @@ function blockRenderAndProceed(json, params){ } } resolveReferences(references); + radioLoad(); } else { console.log("deep in :" +group); if (recursive) seekZblock(json.previous, [group]); -- cgit v1.2.3