Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default maxPlaylistRetries to Infinity
Browse files Browse the repository at this point in the history
evanfarina committed Jun 18, 2021
1 parent 0f35f7e commit 99dd2d9
Showing 2 changed files with 70 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/master-playlist-controller.js
Original file line number Diff line number Diff line change
@@ -140,7 +140,6 @@ export class MasterPlaylistController extends videojs.EventTarget {
bandwidth,
externVhs,
useCueTags,
maxPlaylistRetries,
blacklistDuration,
enableLowInitialPlaylist,
sourceType,
@@ -152,6 +151,12 @@ export class MasterPlaylistController extends videojs.EventTarget {
throw new Error('A non-empty playlist URL or JSON manifest string is required');
}

let { maxPlaylistRetries } = options;

if (maxPlaylistRetries === null || typeof maxPlaylistRetries === 'undefined') {
maxPlaylistRetries = Infinity;
}

Vhs = externVhs;

this.experimentalBufferBasedABR = Boolean(experimentalBufferBasedABR);
64 changes: 64 additions & 0 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
@@ -5796,6 +5796,70 @@ QUnit.test('true if duration < 30', function(assert) {
assert.ok(mpc.shouldSwitchToMedia_(nextPlaylist), 'should switch');
});

QUnit.test('maxPlaylistRetries defaults to Infinity when no value or null/undefined is provided', function(assert) {
const playerNull = createPlayer({
html5: {
vhs: {
maxPlaylistRetries: null
}
}
});

const playerUndefined = createPlayer({
html5: {
vhs: {
maxPlaylistRetries: undefined
}
}
});

const playerNoValue = createPlayer();

playerNull.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

playerUndefined.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

playerNoValue.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

assert.equal(playerNull.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when null is provided as the option value');
assert.equal(playerUndefined.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when undefined is provided as the option value');
assert.equal(playerNoValue.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, Infinity, 'maxPlaylistRetries defaults to Infinity when no value is provided');
});

QUnit.test('maxPlaylistRetries is set when zero is passed as the option\'s value', function(assert) {
const player = createPlayer({
html5: {
vhs: {
maxPlaylistRetries: 0
}
}
});

player.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

assert.equal(player.tech_.vhs.masterPlaylistController_.maxPlaylistRetries, 0, 'maxPlaylistRetries was set to zero');
});

QUnit.test('true duration < 16 with experimentalBufferBasedABR', function(assert) {
const mpc = this.masterPlaylistController;
const nextPlaylist = {id: 'foo', endList: true};

0 comments on commit 99dd2d9

Please sign in to comment.