diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 6b7283762..794386864 100644 --- a/src/videojs-http-streaming.js +++ b/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 diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index f20bab5fa..e8f259329 100644 --- a/test/videojs-http-streaming.test.js +++ b/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();