Skip to content

Commit 384bd35

Browse files
author
Joel Steres
committed
Handle http status code errors in loadBuffer as errors
1 parent c6b3e9e commit 384bd35

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lib/webaudiox.loadbuffer.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,26 @@ WebAudiox.loadBuffer = function(context, url, onLoad, onError){
2121
// counter inProgress request
2222
WebAudiox.loadBuffer.inProgressCount++
2323
request.onload = function(){
24-
context.decodeAudioData(request.response, function(buffer){
25-
// counter inProgress request
26-
WebAudiox.loadBuffer.inProgressCount--
27-
// notify the callback
28-
onLoad(buffer)
29-
// notif
30-
WebAudiox.loadBuffer.onLoad(context, url, buffer)
31-
}, function(){
24+
if( request.status < 400 ){
25+
context.decodeAudioData(request.response, function(buffer){
26+
// counter inProgress request
27+
WebAudiox.loadBuffer.inProgressCount--
28+
// notify the callback
29+
onLoad(buffer)
30+
// notif
31+
WebAudiox.loadBuffer.onLoad(context, url, buffer)
32+
}, function(){
33+
// counter inProgress request
34+
WebAudiox.loadBuffer.inProgressCount--
35+
// notify the callback
36+
onError()
37+
})
38+
} else {
3239
// counter inProgress request
3340
WebAudiox.loadBuffer.inProgressCount--
3441
// notify the callback
3542
onError()
36-
})
43+
}
3744
}
3845
request.send()
3946
}

0 commit comments

Comments
 (0)