Skip to content

Commit

Permalink
feat: add initialBandwidth option at the tech level (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev authored Apr 27, 2021
1 parent ab305f8 commit 2071008
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ class VhsHandler extends Component {
videojs.log.warn('Using hls options is deprecated. Use vhs instead.');
}

// if a tech level `initialBandwidth` option was passed
// use that over the VHS level `bandwidth` option
if (typeof options.initialBandwidth === 'number') {
this.options_.bandwidth = options.initialBandwidth;
}

this.logger_ = logger('VhsHandler');

// tech.player() is deprecated but setup a reference to HLS for
Expand Down
30 changes: 30 additions & 0 deletions test/videojs-http-streaming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2913,6 +2913,36 @@ QUnit.test(
}
);

QUnit.test('respects initialBandwidth option on the tech', function(assert) {
this.player.dispose();
this.player = createPlayer({ html5: { initialBandwidth: 0 } });

this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

openMediaSource(this.player, this.clock);
assert.equal(this.player.tech_.vhs.bandwidth, 0, 'set bandwidth to 0');
});

QUnit.test('initialBandwidth option on the tech take precedence on over vhs bandwidth option', function(assert) {
this.player.dispose();
this.player = createPlayer({ html5: { initialBandwidth: 0, vhs: { bandwidth: 100 } } });

this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});

this.clock.tick(1);

openMediaSource(this.player, this.clock);
assert.equal(this.player.tech_.vhs.bandwidth, 0, 'set bandwidth to 0');
});

QUnit.test('uses default bandwidth if browser is Android', function(assert) {
this.player.dispose();

Expand Down

0 comments on commit 2071008

Please sign in to comment.