Merge branch 'bugfix/multiple-tracks-playing-at-once' into 'develop'

Stop all other tracks when loading a new track

Closes #1213 and #1387

See merge request funkwhale/funkwhale!1291
environments/review-docs-trace-4s67rt/deployments/6715
Georg Krause 2021-04-08 07:55:23 +00:00
commit f7b2f0f259
2 zmienionych plików z 15 dodań i 17 usunięć

Wyświetl plik

@ -0,0 +1 @@
Fix tracks playing in the background without the ability to control them (#1213) (#1387)

Wyświetl plik

@ -304,21 +304,15 @@ export default {
toggleMute: "player/toggleMute", toggleMute: "player/toggleMute",
}), }),
async getTrackData (trackData) { async getTrackData (trackData) {
let data = null // use previously fetched trackData
if (!trackData.uploads.length || trackData.uploads.length === 0) { if (trackData.uploads.length) return trackData
// we don't have upload informations for this track, we need to fetch it
await axios.get(`tracks/${trackData.id}/`).then((response) => { // we don't have any information for this track, we need to fetch it
data = response.data return axios.get(`tracks/${trackData.id}/`)
}, error => { .then(
data = null response => response.data,
}) err => null
} else { )
return trackData
}
if (data === null) {
return
}
return data
}, },
shuffle() { shuffle() {
let disabled = this.queue.tracks.length === 0 let disabled = this.queue.tracks.length === 0
@ -611,8 +605,11 @@ export default {
async loadSound (newValue, oldValue) { async loadSound (newValue, oldValue) {
let trackData = newValue let trackData = newValue
let oldSound = this.currentSound let oldSound = this.currentSound
// stop all other sounds!
// we do this here (before the track has loaded) to get a predictable
// song order.
Howler.stop()
if (oldSound && trackData !== oldValue) { if (oldSound && trackData !== oldValue) {
oldSound.stop(this.soundId)
this.soundId = null this.soundId = null
} }
if (!trackData) { if (!trackData) {
@ -620,7 +617,7 @@ export default {
} }
if (!this.isShuffling && trackData != oldValue) { if (!this.isShuffling && trackData != oldValue) {
trackData = await this.getTrackData(trackData) trackData = await this.getTrackData(trackData)
if (trackData === null) { if (trackData == null) {
this.handleError({}) this.handleError({})
} }
this.currentSound = this.getSound(trackData) this.currentSound = this.getSound(trackData)