Skip to content
Snippets Groups Projects
Verified Commit cd9cd4d0 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed some playback issues

parent a8fbd85a
No related branches found
No related tags found
No related merge requests found
...@@ -254,9 +254,11 @@ export default { ...@@ -254,9 +254,11 @@ export default {
maxPreloaded: 3, maxPreloaded: 3,
preloadDelay: 15, preloadDelay: 15,
soundsCache: [], soundsCache: [],
soundId: null
} }
}, },
mounted() { mounted() {
Howler.unload() // clear existing cache, if any
// we trigger the watcher explicitely it does not work otherwise // we trigger the watcher explicitely it does not work otherwise
this.sliderVolume = this.volume this.sliderVolume = this.volume
// this is needed to unlock audio playing under some browsers, // this is needed to unlock audio playing under some browsers,
...@@ -369,7 +371,7 @@ export default { ...@@ -369,7 +371,7 @@ export default {
}, },
onunlock: function () { onunlock: function () {
if (this.$store.state.player.playing) { if (this.$store.state.player.playing) {
self.sound.play() self.soundId = self.sound.play()
} }
}, },
onload: function () { onload: function () {
...@@ -506,7 +508,7 @@ export default { ...@@ -506,7 +508,7 @@ export default {
let onlyTrack = this.$store.state.queue.tracks.length === 1 let onlyTrack = this.$store.state.queue.tracks.length === 1
if (this.looping === 1 || (onlyTrack && this.looping === 2)) { if (this.looping === 1 || (onlyTrack && this.looping === 2)) {
this.currentSound.seek(0) this.currentSound.seek(0)
this.currentSound.play() this.soundId = this.currentSound.play()
} else { } else {
this.$store.dispatch('player/trackEnded', this.currentTrack) this.$store.dispatch('player/trackEnded', this.currentTrack)
} }
...@@ -546,7 +548,8 @@ export default { ...@@ -546,7 +548,8 @@ export default {
let trackData = newValue let trackData = newValue
let oldSound = this.currentSound let oldSound = this.currentSound
if (oldSound && trackData !== oldValue) { if (oldSound && trackData !== oldValue) {
oldSound.pause() oldSound.stop(this.soundId)
this.soundId = null
} }
if (!trackData) { if (!trackData) {
return return
...@@ -559,7 +562,7 @@ export default { ...@@ -559,7 +562,7 @@ export default {
this.currentSound = this.getSound(trackData) this.currentSound = this.getSound(trackData)
this.$store.commit('player/isLoadingAudio', true) this.$store.commit('player/isLoadingAudio', true)
if (this.playing) { if (this.playing) {
this.currentSound.play() this.soundId = this.currentSound.play()
this.$store.commit('player/playing', true) this.$store.commit('player/playing', true)
this.observeProgress(true) this.observeProgress(true)
} }
...@@ -675,9 +678,9 @@ export default { ...@@ -675,9 +678,9 @@ export default {
playing: async function (newValue) { playing: async function (newValue) {
if (this.currentSound) { if (this.currentSound) {
if (newValue === true) { if (newValue === true) {
this.currentSound.play() this.soundId = this.currentSound.play(this.soundId)
} else { } else {
this.currentSound.pause() this.currentSound.pause(this.soundId)
} }
} else { } else {
await this.loadSound(this.currentTrack, null) await this.loadSound(this.currentTrack, null)
...@@ -690,6 +693,11 @@ export default { ...@@ -690,6 +693,11 @@ export default {
this.setCurrentTime(newValue) this.setCurrentTime(newValue)
} }
this.isUpdatingTime = false this.isUpdatingTime = false
},
emptyQueue (newValue) {
if (newValue) {
Howler.unload()
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment