blob: 991eb6c30490053eb1805b79d2b05455832892a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
let isInfoShown = true;
function GetSongs() {
fetch("/api/getSongs").then(r => r.json().then(body => {
console.log(body);
}));
}
function SetRandomSong() {
fetch("/api/randomSong").then(r => r.json().then(body => {
const player = document.getElementById("mainAudio");
console.log(player);
console.log(body);
player.src = "/api/getSong?name=" + encodeURI(body.Name);
document.getElementById("Artist").innerHTML = "Artist: " + body.Meta.Author;
document.getElementById("Title").innerHTML = "Title: " + body.Meta.Name;
document.getElementById("Album").innerHTML = "Album: " + body.Meta.Album;
document.getElementById("Start").innerHTML = "Start: " + body.Start + "s";
player.play();
player.currentTime = body.Start
document.getElementById("Status").innerHTML = "Playing";
}));
}
function Pause() {
const player = document.getElementById("mainAudio");
player.pause();
document.getElementById("Status").innerHTML = "Paused";
}
function Resume() {
const player = document.getElementById("mainAudio");
player.play();
document.getElementById("Status").innerHTML = "Playing";
}
function ToggleInfo() {
if (isInfoShown) {
document.getElementById("InfoBlock").style.display = 'none';
document.getElementById("ToggleBtn").innerHTML = 'Show info';
isInfoShown = false;
} else {
document.getElementById("InfoBlock").style.display = 'block';
document.getElementById("ToggleBtn").innerHTML = 'Hide info';
isInfoShown = true;
}
}
function SetVolume() {
const player = document.getElementById("mainAudio");
const slider = document.getElementById("volumeRange");
player.volume = slider.value / 100;
}
|