fix bug caused by script defer

This commit is contained in:
IrosTheBeggar 2021-12-02 13:43:38 -05:00
parent b4a4e54405
commit 800a915455
2 changed files with 51 additions and 50 deletions

View File

@ -102,7 +102,7 @@ const VUEPLAYERCORE = (() => {
}
},
template: `
<li v-on:click="goToSong($event)" class="pointer collection-item" v-bind:class="{ playing: (this.index === positionCache.val), playError: (this.songError && this.songError === true) }" >
<li v-on:click="goToSong($event)" class="pointer collection-item" v-bind:class="{ playing: (this.index === positionCache.val), playError: (this.songError && this.songError === true) }" >
<div class="playlist-text">{{ comtext }}</div>
<a v-on:click.stop="downloadSong($event)" class="secondary-content">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 12v7H5v-7H3v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zm-6 .67l2.59-2.58L17 11.5l-5 5-5-5 1.41-1.41L11 12.67V3h2z"/></svg>

View File

@ -31,55 +31,6 @@
<!-- mStream Player -->
<script src="../assets/js/mstream.player.js"></script>
<script defer src="../assets/js/mstream.vue.player.js"></script>
<!-- Boot Up App -->
<script defer>
// load the playlist
sharedPlaylist.playlist.forEach(item => {
const newSong = {
url: `../media/${item}?token=${sharedPlaylist.token}`,
filepath: item,
authToken: sharedPlaylist.token,
metadata: {}
};
MSTREAMPLAYER.addSong(newSong, true);
fetch('../api/v1/db/metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'filepath': item,
'token': sharedPlaylist.token
})
})
.then(async (response) => {
if (response.ok !== true) {
throw new Error(response);
}
const data = await response.json();
// handle success
if (data.metadata) {
newSong.metadata = data.metadata;
MSTREAMPLAYER.resetCurrentMetadata();
}
})
.catch((error) => {
console.log(error);
// TODO: Don't spam error messages when an entire playlist fails to load
iziToast.warning({
title: 'Metadata Lookup Failed',
position: 'topCenter',
timeout: 3500
});
});
});
</script>
<style>
.row-mod {
margin-bottom: 0px !important;
@ -215,4 +166,54 @@
</ul>
</div>
</div>
<script src="../assets/js/mstream.vue.player.js"></script>
<!-- Boot Up App -->
<script>
// load the playlist
sharedPlaylist.playlist.forEach(item => {
const newSong = {
url: `../media/${item}?token=${sharedPlaylist.token}`,
filepath: item,
authToken: sharedPlaylist.token,
metadata: {}
};
MSTREAMPLAYER.addSong(newSong, true);
fetch('../api/v1/db/metadata', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'filepath': item,
'token': sharedPlaylist.token
})
})
.then(async (response) => {
if (response.ok !== true) {
throw new Error(response);
}
const data = await response.json();
// handle success
if (data.metadata) {
newSong.metadata = data.metadata;
MSTREAMPLAYER.resetCurrentMetadata();
}
})
.catch((error) => {
console.log(error);
// TODO: Don't spam error messages when an entire playlist fails to load
iziToast.warning({
title: 'Metadata Lookup Failed',
position: 'topCenter',
timeout: 3500
});
});
});
</script>
</body>