diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index 0562b90a0b20282be8c186a404339c3376116929..0ad8fe7c6f61385bed9af6568677dd8158337f1b 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -255,11 +255,16 @@ export default { preloadDelay: 15, soundsCache: [], soundId: null, - playTimeout: null + playTimeout: null, + nextTrackPreloaded: false } }, mounted() { + this.$store.dispatch('player/updateProgress', 0) + this.$store.commit('player/playing', false) + this.$store.commit("player/isLoadingAudio", false) Howler.unload() // clear existing cache, if any + this.nextTrackPreloaded = false // we trigger the watcher explicitely it does not work otherwise this.sliderVolume = this.volume // this is needed to unlock audio playing under some browsers, @@ -274,10 +279,12 @@ export default { this.getSound(this.currentTrack) } }, - destroyed() { + beforeDestroy () { this.dummyAudio.unload() this.observeProgress(false) }, + destroyed() { + }, methods: { ...mapActions({ togglePlay: "player/togglePlay", @@ -473,8 +480,9 @@ export default { this.$store.dispatch('player/updateProgress', t) this.updateBuffer(this.currentSound._sounds[0]._node) let toPreload = this.$store.state.queue.tracks[this.currentIndex + 1] - if (toPreload && !this.getSoundFromCache(toPreload) && (t > this.preloadDelay || d - t < 30)) { + if (!this.nextTrackPreloaded && toPreload && !this.getSoundFromCache(toPreload) && (t > this.preloadDelay || d - t < 30)) { this.getSound(toPreload) + this.nextTrackPreloaded = true } } }, @@ -677,6 +685,7 @@ export default { if (newValue === oldValue) { return } + this.nextTrackPreloaded = false clearTimeout(this.playTimeout) let self = this if (this.currentSound) {