// var radio = document.querySelector("#radio-player"); // var radioButton = document.querySelector("#radio-button-controller"); radio.addEventListener("play", ()=>{ radioButton.innerHTML = ' '; }) radio.addEventListener("pause", ()=>{ radioButton.innerHTML = ' '; }) 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 { radioLoad(); } } radio.addEventListener("ended", radioLoadNextAndPlay); function radioToggle() { if (radio.paused) { radio.play(); } else { radio.pause(); } } // vim: tabstop=4 shiftwidth=4 expandtab softtabstop=4