c5991ff3 by Matthew Neil Committed by Jon-Carlos Rivera

allow for initial bandwidth option of 0 (#855)

1 parent a96dbc3e
...@@ -342,7 +342,9 @@ class HlsHandler extends Component { ...@@ -342,7 +342,9 @@ class HlsHandler extends Component {
342 // start playlist selection at a reasonable bandwidth for 342 // start playlist selection at a reasonable bandwidth for
343 // broadband internet 343 // broadband internet
344 // 0.5 MB/s 344 // 0.5 MB/s
345 this.options_.bandwidth = this.options_.bandwidth || 4194304; 345 if (typeof this.options_.bandwidth !== 'number') {
346 this.options_.bandwidth = 4194304;
347 }
346 348
347 // grab options passed to player.src 349 // grab options passed to player.src
348 ['withCredentials', 'bandwidth'].forEach((option) => { 350 ['withCredentials', 'bandwidth'].forEach((option) => {
......
...@@ -1262,6 +1262,32 @@ QUnit.test('if mode global option is used, mode is set to global option', functi ...@@ -1262,6 +1262,32 @@ QUnit.test('if mode global option is used, mode is set to global option', functi
1262 videojs.options.hls = hlsOptions; 1262 videojs.options.hls = hlsOptions;
1263 }); 1263 });
1264 1264
1265 QUnit.test('respects bandwidth option of 0', function() {
1266 this.player.dispose();
1267 this.player = createPlayer({ html5: { hls: { bandwidth: 0 } } });
1268
1269 this.player.src({
1270 src: 'http://example.com/media.m3u8',
1271 type: 'application/vnd.apple.mpegurl'
1272 });
1273
1274 openMediaSource(this.player, this.clock);
1275 QUnit.equal(this.player.tech_.hls.bandwidth, 0, 'set bandwidth to 0');
1276 });
1277
1278 QUnit.test('uses default bandwidth option if non-numerical value provided', function() {
1279 this.player.dispose();
1280 this.player = createPlayer({ html5: { hls: { bandwidth: 'garbage' } } });
1281
1282 this.player.src({
1283 src: 'http://example.com/media.m3u8',
1284 type: 'application/vnd.apple.mpegurl'
1285 });
1286
1287 openMediaSource(this.player, this.clock);
1288 QUnit.equal(this.player.tech_.hls.bandwidth, 4194304, 'set bandwidth to default');
1289 });
1290
1265 QUnit.test('does not break if the playlist has no segments', function() { 1291 QUnit.test('does not break if the playlist has no segments', function() {
1266 this.player.src({ 1292 this.player.src({
1267 src: 'manifest/master.m3u8', 1293 src: 'manifest/master.m3u8',
......