Skip to content

Commit

Permalink
fix: actually default maxPlaylistRetries to Infinity (#1142)
Browse files Browse the repository at this point in the history
Followup to #1098 where the default should've been Infinity, but it got lost in translation.

Co-authored-by: Evan farina <[email protected]>
  • Loading branch information
evanfarina and evanfarina authored Jun 22, 2021
1 parent 0f35f7e commit 4428e3a
Show file tree
Hide file tree
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
Expand Up @@ -140,7 +140,6 @@ export class MasterPlaylistController extends videojs.EventTarget {
bandwidth,
externVhs,
useCueTags,
maxPlaylistRetries,
blacklistDuration,
enableLowInitialPlaylist,
sourceType,
Expand All @@ -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);
Expand Down
64 changes: 64 additions & 0 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 4428e3a

Please sign in to comment.