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

This commit is contained in:
Eliot Berriot 2019-05-07 11:59:41 +02:00
parent bc87674b34
commit 58195cd4d1
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
1 changed files with 14 additions and 4 deletions

View File

@ -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
},