From 8c8ae9cce8c0f992fe6701a203a55870772808d8 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 11 Nov 2024 04:31:53 +0200 Subject: Added Radio --- src/js/arching-kaos-decentralized-radio.js | 79 +++++++++++++++++++----------- 1 file changed, 51 insertions(+), 28 deletions(-) (limited to 'src/js/arching-kaos-decentralized-radio.js') diff --git a/src/js/arching-kaos-decentralized-radio.js b/src/js/arching-kaos-decentralized-radio.js index c8b99d1..061a142 100644 --- a/src/js/arching-kaos-decentralized-radio.js +++ b/src/js/arching-kaos-decentralized-radio.js @@ -1,12 +1,22 @@ +/* Arching Kaos Dentralized Radio + * + * Kaotisk Hund - 2024 + * + * @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 + * + */ // var radio = document.querySelector("#radio-player"); // var radioButton = document.querySelector("#radio-button-controller"); -radio.addEventListener("play", ()=>{ - radioButton.innerHTML = ' '; -}) -radio.addEventListener("pause", ()=>{ - radioButton.innerHTML = ' '; -}) +if (radio !== null ) +{ + radio.addEventListener("play", ()=>{ + radioButton.innerHTML = ' '; + }) + radio.addEventListener("pause", ()=>{ + radioButton.innerHTML = ' '; + }) +} var played = []; var list = mixtapeIds; @@ -15,41 +25,54 @@ 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 ) + if (radio !== null ) { + var elem = document.querySelector('#'+mixtapeIds[0]).firstChild.cloneNode(true); + currentPlaying = 0; radio.appendChild(elem); - radio.load(); radio.play(); } - else +} + +function radioLoadNextAndPlay() +{ + if (radio !== null ) { - radioLoad(); + 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 + { + radioLoad(); + } } } -radio.addEventListener("ended", radioLoadNextAndPlay); +if ( radio !== null ) +{ + radio.addEventListener("ended", radioLoadNextAndPlay); +} function radioToggle() { - if (radio.paused) - { - radio.play(); - } - else + if ( radio !== null ) { - radio.pause(); + if (radio.paused) + { + radio.play(); + } + else + { + radio.pause(); + } } } // vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4 +// @license-end -- cgit v1.2.3