summaryrefslogtreecommitdiff
path: root/static/index.js
blob: 6cda2f71814193f8d0171e3d1ebd418893d93dff (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

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);
        player.play();

        document.getElementById("Artist").innerHTML = "Artist: " + body.Meta.Name;
        document.getElementById("Title").innerHTML =  "Title: " + body.Meta.Author;
        document.getElementById("Album").innerHTML =  "Album: " + body.Meta.Album;
        document.getElementById("Start").innerHTML =  "Start: " + body.Start + "s";

    }));
}

function Pause() {
    const player = document.getElementById("mainAudio");
    player.pause();
    console.log("Paused audio");
}

function Resume() {
    const player = document.getElementById("mainAudio");
    player.play();
    console.log("Paused audio");
}