Browse Source

feat: add initialBandwidth option at the tech level (#1122)

pull/1123/head
Gary Katsevman 4 years ago
committed by GitHub
parent
commit
2071008c23
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/videojs-http-streaming.js
  2. 30
      test/videojs-http-streaming.test.js

6
src/videojs-http-streaming.js

@ -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

30
test/videojs-http-streaming.test.js

@ -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();

Loading…
Cancel
Save