From 59445b6146018a141a73cc740db88bbc21ddf3bf Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Thu, 15 Mar 2018 22:57:53 +0100 Subject: [PATCH] Fixed position not being reseted properly when playing the same track multiple times in a row --- changes/changelog.d/queue-same-track.bugfix | 1 + front/src/components/audio/Player.vue | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 changes/changelog.d/queue-same-track.bugfix diff --git a/changes/changelog.d/queue-same-track.bugfix b/changes/changelog.d/queue-same-track.bugfix new file mode 100644 index 00000000..11a1a08c --- /dev/null +++ b/changes/changelog.d/queue-same-track.bugfix @@ -0,0 +1 @@ +Fixed position not being reseted properly when playing the same track multiple times in a row diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index b5cbd8f8..0c5ed44b 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -3,7 +3,7 @@ <div class="player"> <audio-track ref="currentAudio" - v-if="currentTrack" + v-if="renderAudio && currentTrack" :key="(currentIndex, currentTrack.id)" :is-current="true" :start-time="$store.state.player.currentTime" @@ -151,6 +151,7 @@ export default { data () { let defaultAmbiantColors = [[46, 46, 46], [46, 46, 46], [46, 46, 46], [46, 46, 46]] return { + renderAudio: true, sliderVolume: this.volume, Track: Track, defaultAmbiantColors: defaultAmbiantColors, @@ -163,7 +164,6 @@ export default { }, methods: { ...mapActions({ - pause: 'player/pause', togglePlay: 'player/togglePlay', clean: 'queue/clean', next: 'queue/next', @@ -230,6 +230,17 @@ export default { this.ambiantColors = this.defaultAmbiantColors } }, + currentIndex (newValue, oldValue) { + if (newValue !== oldValue) { + // why this? to ensure the audio tag is deleted and fully + // rerendered, so we don't have any issues with cached position + // or whatever + this.renderAudio = false + this.$nextTick(() => { + this.renderAudio = true + }) + } + }, volume (newValue) { this.sliderVolume = newValue }, -- GitLab