Verified Commit 58195cd4 authored by Eliot Berriot's avatar Eliot Berriot 💬

Added small timeout before playback to avoid loading lots of tracks when skipping through the queue

parent bc87674b
......@@ -254,7 +254,8 @@ export default {
maxPreloaded: 3,
preloadDelay: 15,
soundsCache: [],
soundId: null
soundId: null,
playTimeout: null
}
},
mounted() {
......@@ -577,6 +578,7 @@ export default {
this.soundId = this.currentSound.play()
this.$store.commit('player/errored', false)
this.$store.commit('player/playing', true)
this.$store.dispatch('player/updateProgress', 0)
this.observeProgress(true)
}
}
......@@ -672,10 +674,18 @@ export default {
watch: {
currentTrack: {
async handler (newValue, oldValue) {
await this.loadSound(newValue, oldValue)
if (!newValue || !newValue.album.cover) {
this.ambiantColors = this.defaultAmbiantColors
clearTimeout(this.playTimeout)
let self = this
if (this.currentSound) {
this.currentSound.pause()
}
this.$store.commit("player/isLoadingAudio", true)
this.playTimeout = setTimeout(async () => {
await self.loadSound(newValue, oldValue)
if (!newValue || !newValue.album.cover) {
self.ambiantColors = self.defaultAmbiantColors
}
}, 500);
},
immediate: false
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment