diff --git a/src/master-playlist-controller.js b/src/master-playlist-controller.js index 8511530ee..23cfa241a 100644 --- a/src/master-playlist-controller.js +++ b/src/master-playlist-controller.js @@ -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) { @@ -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(); diff --git a/test/videojs-contrib-hls.test.js b/test/videojs-contrib-hls.test.js index 5a9f438f5..58c998d72 100644 --- a/test/videojs-contrib-hls.test.js +++ b/test/videojs-contrib-hls.test.js @@ -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 @@ -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); @@ -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); @@ -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