delay songlist.json fetch until necessary
This commit is contained in:
parent
95423a7e4d
commit
3543742439
|
|
@ -59,10 +59,17 @@ function addVolume(n) {
|
|||
setVol(Number(localStorage.getItem('volume') ?? Math.ceil(n / 2)))();
|
||||
music.appendChild(vol);
|
||||
}
|
||||
fetch('/static/songlist.json').then(e => e.json()).then(songs => {
|
||||
let songs = [];
|
||||
function playSong() {
|
||||
fetch('/static/songlist.json').then(e => e.json()).then(e => {
|
||||
songs = e;
|
||||
shuffle(songs);
|
||||
playSong = _playSong;
|
||||
_playSong()
|
||||
});
|
||||
}
|
||||
let n = 0;
|
||||
shuffle(songs);
|
||||
function playSong() {
|
||||
function _playSong() {
|
||||
let song = songs[n] ?? songs[n = 0];
|
||||
audio.src = song.href;
|
||||
if (song.src) popup(`\u266b - ${song.src} (${song.artist}) - ${song.name}`);
|
||||
|
|
@ -96,4 +103,3 @@ fetch('/static/songlist.json').then(e => e.json()).then(songs => {
|
|||
playSong(++n);
|
||||
});
|
||||
addVolume(5);
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue