Check for request errors before checking if the request was aborted
Make sure the request did not receive an error status code (and hence the response is unavailable) before assuming it was aborted.
Showing
1 changed file
with
7 additions
and
7 deletions
... | @@ -378,22 +378,22 @@ var | ... | @@ -378,22 +378,22 @@ var |
378 | // the segment request is no longer outstanding | 378 | // the segment request is no longer outstanding |
379 | segmentXhr = null; | 379 | segmentXhr = null; |
380 | 380 | ||
381 | // stop processing if the request was aborted | ||
382 | if (!this.response) { | ||
383 | return; | ||
384 | } | ||
385 | |||
386 | // trigger an error if the request was not successful | 381 | // trigger an error if the request was not successful |
387 | if (this.status >= 400) { | 382 | if (this.status >= 400) { |
388 | player.hls.error = { | 383 | player.hls.error = { |
389 | status: segmentXhr.status, | 384 | status: this.status, |
390 | message: 'HLS segment request error at URL: ' + segmentUri, | 385 | message: 'HLS segment request error at URL: ' + segmentUri, |
391 | code: (segmentXhr.status >= 500) ? 4 : 2 | 386 | code: (this.status >= 500) ? 4 : 2 |
392 | }; | 387 | }; |
393 | player.trigger('error'); | 388 | player.trigger('error'); |
394 | return; | 389 | return; |
395 | } | 390 | } |
396 | 391 | ||
392 | // stop processing if the request was aborted | ||
393 | if (!this.response) { | ||
394 | return; | ||
395 | } | ||
396 | |||
397 | // calculate the download bandwidth | 397 | // calculate the download bandwidth |
398 | player.hls.segmentXhrTime = (+new Date()) - startTime; | 398 | player.hls.segmentXhrTime = (+new Date()) - startTime; |
399 | player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; | 399 | player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; | ... | ... |
-
Please register or sign in to post a comment