Pass playlist loader errors to endOfStream
If an error occurs downloading an M3U8, call endOfStream on the active MediaSource with the appropriate error code.
Showing
2 changed files
with
13 additions
and
9 deletions
... | @@ -210,6 +210,14 @@ videojs.Hls.prototype.src = function(src) { | ... | @@ -210,6 +210,14 @@ videojs.Hls.prototype.src = function(src) { |
210 | }.bind(this)); | 210 | }.bind(this)); |
211 | 211 | ||
212 | this.playlists.on('error', function() { | 212 | this.playlists.on('error', function() { |
213 | // close the media source with the appropriate error type | ||
214 | if (this.playlists.error.code === 2) { | ||
215 | this.mediaSource.endOfStream('network'); | ||
216 | } else if (this.playlists.error.code === 4) { | ||
217 | this.mediaSource.endOfStream('decode'); | ||
218 | } | ||
219 | |||
220 | // if this error is unrecognized, pass it along to the tech | ||
213 | this.tech_.error(this.playlists.error); | 221 | this.tech_.error(this.playlists.error); |
214 | }.bind(this)); | 222 | }.bind(this)); |
215 | 223 | ... | ... |
... | @@ -104,7 +104,9 @@ var | ... | @@ -104,7 +104,9 @@ var |
104 | }); | 104 | }); |
105 | 105 | ||
106 | // endOfStream triggers an exception if flash isn't available | 106 | // endOfStream triggers an exception if flash isn't available |
107 | player.tech.hls.mediaSource.endOfStream = function() {}; | 107 | player.tech.hls.mediaSource.endOfStream = function(error) { |
108 | this.error_ = error; | ||
109 | }; | ||
108 | }, | 110 | }, |
109 | standardXHRResponse = function(request) { | 111 | standardXHRResponse = function(request) { |
110 | if (!request.url) { | 112 | if (!request.url) { |
... | @@ -583,11 +585,7 @@ test('re-initializes the handler for each source', function() { | ... | @@ -583,11 +585,7 @@ test('re-initializes the handler for each source', function() { |
583 | notStrictEqual(firstMSE, secondMSE, 'the media source object is not reused'); | 585 | notStrictEqual(firstMSE, secondMSE, 'the media source object is not reused'); |
584 | }); | 586 | }); |
585 | 587 | ||
586 | QUnit.skip('triggers an error when a master playlist request errors', function() { | 588 | test('triggers an error when a master playlist request errors', function() { |
587 | var errors = 0; | ||
588 | player.on('error', function() { | ||
589 | errors++; | ||
590 | }); | ||
591 | player.src({ | 589 | player.src({ |
592 | src: 'manifest/master.m3u8', | 590 | src: 'manifest/master.m3u8', |
593 | type: 'application/vnd.apple.mpegurl' | 591 | type: 'application/vnd.apple.mpegurl' |
... | @@ -595,9 +593,7 @@ QUnit.skip('triggers an error when a master playlist request errors', function() | ... | @@ -595,9 +593,7 @@ QUnit.skip('triggers an error when a master playlist request errors', function() |
595 | openMediaSource(player); | 593 | openMediaSource(player); |
596 | requests.pop().respond(500); | 594 | requests.pop().respond(500); |
597 | 595 | ||
598 | ok(player.error(), 'an error is triggered'); | 596 | equal(player.tech.hls.mediaSource.error_, 'network', 'a network error is triggered'); |
599 | strictEqual(1, errors, 'fired one error'); | ||
600 | strictEqual(2, player.error().code, 'a network error is triggered'); | ||
601 | }); | 597 | }); |
602 | 598 | ||
603 | test('downloads media playlists after loading the master', function() { | 599 | test('downloads media playlists after loading the master', function() { | ... | ... |
-
Please register or sign in to post a comment