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

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

parent a4e31cdb
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment