From 0d3df8ab77613d463fe2985b40b2915fffcf626e Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Thu, 26 Dec 2019 15:35:13 +0100 Subject: [PATCH] Fix #970: short audio glitch when switching switching to another track with player paused --- changes/changelog.d/970.bugfix | 1 + front/src/components/audio/Player.vue | 14 ++++++-------- front/src/store/queue.js | 1 - front/tests/unit/specs/store/queue.spec.js | 3 --- 4 files changed, 7 insertions(+), 12 deletions(-) create mode 100644 changes/changelog.d/970.bugfix diff --git a/changes/changelog.d/970.bugfix b/changes/changelog.d/970.bugfix new file mode 100644 index 000000000..400e54f74 --- /dev/null +++ b/changes/changelog.d/970.bugfix @@ -0,0 +1 @@ +Fixed short audio glitch when switching switching to another track with player paused (#970) diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index 71365a893..824007d7c 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -361,7 +361,7 @@ export default { self.ended() }, onunlock: function () { - if (self.$store.state.player.playing) { + if (self.$store.state.player.playing && self.sound) { self.soundId = self.sound.play(self.soundId) } }, @@ -581,13 +581,11 @@ export default { } this.currentSound = this.getSound(trackData) this.$store.commit('player/isLoadingAudio', true) - if (this.playing) { - 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) - } + 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) } }, toggleMobilePlayer () { diff --git a/front/src/store/queue.js b/front/src/store/queue.js index a750dd7f0..5514db921 100644 --- a/front/src/store/queue.js +++ b/front/src/store/queue.js @@ -140,7 +140,6 @@ export default { currentIndex ({commit, state, rootState, dispatch}, index) { commit('ended', false) commit('player/currentTime', 0, {root: true}) - commit('player/playing', true, {root: true}) commit('currentIndex', index) if (state.tracks.length - index <= 2 && rootState.radios.running) { dispatch('radios/populateQueue', null, {root: true}) diff --git a/front/tests/unit/specs/store/queue.spec.js b/front/tests/unit/specs/store/queue.spec.js index 140ce071a..afdf46c90 100644 --- a/front/tests/unit/specs/store/queue.spec.js +++ b/front/tests/unit/specs/store/queue.spec.js @@ -226,7 +226,6 @@ describe('store/queue', () => { expectedMutations: [ { type: 'ended', payload: false }, { type: 'player/currentTime', payload: 0, options: {root: true} }, - { type: 'player/playing', payload: true, options: {root: true} }, { type: 'currentIndex', payload: 1 } ] }) @@ -239,7 +238,6 @@ describe('store/queue', () => { expectedMutations: [ { type: 'ended', payload: false }, { type: 'player/currentTime', payload: 0, options: {root: true} }, - { type: 'player/playing', payload: true, options: {root: true} }, { type: 'currentIndex', payload: 1 } ] }) @@ -252,7 +250,6 @@ describe('store/queue', () => { expectedMutations: [ { type: 'ended', payload: false }, { type: 'player/currentTime', payload: 0, options: {root: true} }, - { type: 'player/playing', payload: true, options: {root: true} }, { type: 'currentIndex', payload: 1 } ], expectedActions: [