Fixed #46: better handling of HTTP errors when fetching audio file

merge-requests/154/head
Eliot Berriot 2017-12-15 22:03:15 +01:00
rodzic a4e31cdb9d
commit 13eddbfc21
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
3 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ Changelog
------------------
- Import: can now specify search template when querying import sources (#45)
- Player: better handling of errors when fetching the audio file (#46)
0.2.4 (2017-12-14)

Wyświetl plik

@ -26,6 +26,7 @@ class Audio {
if (options.onEnded) {
this.onEnded = options.onEnded
}
this.onError = options.onError
this.state = {
preload: preload,
@ -60,8 +61,12 @@ class Audio {
init (src, options = {}) {
if (!src) throw Error('src must be required')
this.state.startLoad = true
if (this.state.tried === this.state.try) {
if (this.state.tried >= this.state.try) {
this.state.failed = true
logger.default.error('Cannot fetch audio', src)
if (this.onError) {
this.onError(src)
}
return
}
this.$Audio = new window.Audio(src)

Wyświetl plik

@ -140,7 +140,6 @@ class Queue {
} else {
index = index || this.tracks.length
}
console.log('INDEEEEEX', index)
tracks.forEach((t) => {
self.append(t, index, true)
index += 1
@ -243,7 +242,11 @@ class Queue {
rate: 1,
loop: false,
volume: this.state.volume,
onEnded: this.handleAudioEnded.bind(this)
onEnded: this.handleAudioEnded.bind(this),
onError: function (src) {
self.errored = true
self.next()
}
})
this.audio = audio
audio.updateHook('playState', function (e) {