1
0

Updated player's JS.

This commit is contained in:
Alexander Andreev 2023-08-22 03:39:29 +04:00
parent 3837ca9c56
commit 472a68768c
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -44,16 +44,19 @@ document.getElementById("btn-update").addEventListener("click", () => {
setInterval(updateRadioStatus, 45000); setInterval(updateRadioStatus, 45000);
setInterval(updateLastPlayedSong, 45000); setInterval(updateLastPlayedSong, 45000);
let audio = document.getElementsByTagName("audio")[0]; const audio = document.getElementsByTagName("audio")[0];
let volume = $("volume"); const volume = document.getElementsByName("volume")[0];
const audio_src = audio.childNodes[0].src; const audio_src = audio.childNodes[0].src;
audio.hidden = true; audio.hidden = true;
audio.volume = parseFloat(volume.value) / 100.0; audio.volume = parseFloat(volume.value) / 100.0;
document.querySelector("div.player").style.display = "flex"; document.querySelector("#player div:first-child").style.display = "flex";
$("radio").style.display = "flex"; $("player").style.display = "flex";
$("play").addEventListener("click", e => { volume.addEventListener("input", e => {
audio.volume = parseFloat(e.target.value) / 100.0; });
document.getElementsByName("play")[0].addEventListener("click", e => {
if (audio.paused) { if (audio.paused) {
audio.src = audio_src; audio.src = audio_src;
audio.play(); audio.play();
@ -69,7 +72,4 @@ audio.addEventListener("timeupdate", e => {
const s = Math.floor(ct % 60); const s = Math.floor(ct % 60);
const m = Math.floor((ct / 60) % 60); const m = Math.floor((ct / 60) % 60);
const h = Math.floor(ct / 3600); const h = Math.floor(ct / 3600);
$("cur-time").textContent = `${h}h ${m}m ${s}s`; }); document.getElementsByClassName("elapsed")[0].textContent = `${h}h ${m}m ${s}s`; });
volume.addEventListener("input", e => {
audio.volume = parseFloat(e.target.value) / 100.0; });