Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/un-blacklist-playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangs authored Apr 19, 2017
2 parents 7443058 + 0c1217a commit b384f69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
videojs.log.warn('Problem encountered with the current ' +
'HLS playlist. Trying again since it is the only playlist.');

this.tech_.trigger('retryplaylist');
return this.masterPlaylistLoader_.load(isFinalRendition);
}
if (isFinalRendition) {
Expand All @@ -1082,6 +1083,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
}
// Blacklist this playlist
currentPlaylist.excludeUntil = Date.now() + this.blacklistDuration * 1000;
this.tech_.trigger('blacklistplaylist');

// Select a new playlist
nextPlaylist = this.selectPlaylist();
Expand Down
13 changes: 13 additions & 0 deletions test/videojs-contrib-hls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1096,12 +1096,16 @@ QUnit.test('segment 404 should trigger blacklisting of media', function(assert)
QUnit.test('playlist 404 should blacklist media', function(assert) {
let media;
let url;
let blacklistplaylist = 0;
let retryplaylist = 0;

this.player.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(this.player, this.clock);
this.player.tech_.on('blacklistplaylist', () => blacklistplaylist++);
this.player.tech_.on('retryplaylist', () => retryplaylist++);

this.player.tech_.hls.bandwidth = 1e10;
// master
Expand All @@ -1114,6 +1118,8 @@ QUnit.test('playlist 404 should blacklist media', function(assert) {
assert.equal(typeof this.player.tech_.hls.playlists.media_,
'undefined',
'no media is initially set');

assert.equal(blacklistplaylist, 0, 'there is no blacklisted playlist');
// media
this.requests[1].respond(404);
url = this.requests[1].url.slice(this.requests[1].url.lastIndexOf('/') + 1);
Expand All @@ -1123,6 +1129,8 @@ QUnit.test('playlist 404 should blacklist media', function(assert) {
assert.equal(this.env.log.warn.args[0],
'Problem encountered with the current HLS playlist. HLS playlist request error at URL: media.m3u8 Switching to another playlist.',
'log generic error message');
assert.equal(blacklistplaylist, 1, 'there is one blacklisted playlist');
assert.equal(retryplaylist, 0, 'haven\'t retried any playlist');

// request for the final available media
this.requests[2].respond(404);
Expand All @@ -1132,6 +1140,11 @@ QUnit.test('playlist 404 should blacklist media', function(assert) {
// media wasn't blacklisted because it's final rendition
assert.ok(media.excludeUntil, 'second media was blacklisted after playlist 404');
assert.equal(this.env.log.warn.calls, 1, 'warning logged for blacklist');
assert.equal(this.env.log.warn.args[1],
'Problem encountered with the current HLS playlist. Trying again since it is the final playlist.',
'log specific error message for final playlist');
assert.equal(retryplaylist, 1, 'retried final playlist for once');
assert.equal(blacklistplaylist, 1, 'there is one blacklisted playlist');

this.clock.tick(2 * 1000);
// no new request was made since it hasn't been half the segment duration
Expand Down

0 comments on commit b384f69

Please sign in to comment.