diff options
| author | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2025-12-06 12:53:43 +0500 |
|---|---|---|
| committer | Physick <96335032+DegustatorPonos@users.noreply.github.com> | 2025-12-06 12:53:43 +0500 |
| commit | 4b8ef84059e772ef7636c451356680ec5b0983c4 (patch) | |
| tree | 8cabc9b8c275128fd6582cbd74d36212e49776d6 /static | |
| parent | 5fd81183f54662fdf08549c0d635e80166c62fe9 (diff) | |
Random song endpoint
Diffstat (limited to 'static')
| -rw-r--r-- | static/index.html | 4 | ||||
| -rw-r--r-- | static/index.js | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/static/index.html b/static/index.html index 8f1caf6..f6127d7 100644 --- a/static/index.html +++ b/static/index.html @@ -5,5 +5,9 @@ <body> <h1> xdx </h1> <button onclick="GetSongs()"> Get songs </button> + <button onclick="SetRandomSong()"> Set random song </button> + <audio id="mainAudio"> + <source type="audio/mpeg" src=""/> + </audio> </body> </html> diff --git a/static/index.js b/static/index.js index 9f5070b..b7056b1 100644 --- a/static/index.js +++ b/static/index.js @@ -1,5 +1,16 @@ + 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(); + })); +} |
