Correct audio stopping.
This commit is contained in:
parent
b874b533ca
commit
3566e90b1a
@ -47,13 +47,20 @@ setInterval(updateLastPlayedSong, 45000);
|
|||||||
let audio = document.getElementsByTagName("audio")[0];
|
let audio = document.getElementsByTagName("audio")[0];
|
||||||
let volume = $("volume");
|
let volume = $("volume");
|
||||||
|
|
||||||
|
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("div.player").style.display = "flex";
|
||||||
$("radio").style.display = "flex";
|
$("radio").style.display = "flex";
|
||||||
|
|
||||||
$("play").addEventListener("click", e => {
|
$("play").addEventListener("click", e => {
|
||||||
audio.paused && audio.play() || audio.pause();
|
if (audio.paused) {
|
||||||
|
audio.src = audio_src;
|
||||||
|
audio.play();
|
||||||
|
} else {
|
||||||
|
audio.pause();
|
||||||
|
audio.src = "";
|
||||||
|
}
|
||||||
e.target.style.maskImage = audio.paused ? "url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; });
|
e.target.style.maskImage = audio.paused ? "url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; });
|
||||||
|
|
||||||
audio.addEventListener("timeupdate", e => {
|
audio.addEventListener("timeupdate", e => {
|
||||||
|
Loading…
Reference in New Issue
Block a user