8fdc9a07 by David LaPalomento

Pass playlist loader errors to endOfStream

If an error occurs downloading an M3U8, call endOfStream on the active MediaSource with the appropriate error code.
1 parent a31677d5
......@@ -210,6 +210,14 @@ videojs.Hls.prototype.src = function(src) {
}.bind(this));
this.playlists.on('error', function() {
// close the media source with the appropriate error type
if (this.playlists.error.code === 2) {
this.mediaSource.endOfStream('network');
} else if (this.playlists.error.code === 4) {
this.mediaSource.endOfStream('decode');
}
// if this error is unrecognized, pass it along to the tech
this.tech_.error(this.playlists.error);
}.bind(this));
......
......@@ -104,7 +104,9 @@ var
});
// endOfStream triggers an exception if flash isn't available
player.tech.hls.mediaSource.endOfStream = function() {};
player.tech.hls.mediaSource.endOfStream = function(error) {
this.error_ = error;
};
},
standardXHRResponse = function(request) {
if (!request.url) {
......@@ -583,11 +585,7 @@ test('re-initializes the handler for each source', function() {
notStrictEqual(firstMSE, secondMSE, 'the media source object is not reused');
});
QUnit.skip('triggers an error when a master playlist request errors', function() {
var errors = 0;
player.on('error', function() {
errors++;
});
test('triggers an error when a master playlist request errors', function() {
player.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
......@@ -595,9 +593,7 @@ QUnit.skip('triggers an error when a master playlist request errors', function()
openMediaSource(player);
requests.pop().respond(500);
ok(player.error(), 'an error is triggered');
strictEqual(1, errors, 'fired one error');
strictEqual(2, player.error().code, 'a network error is triggered');
equal(player.tech.hls.mediaSource.error_, 'network', 'a network error is triggered');
});
test('downloads media playlists after loading the master', function() {
......