Fixed #46: better handling of HTTP errors when fetching audio file
This commit is contained in:
parent
a4e31cdb9d
commit
13eddbfc21
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue