826f480b by David LaPalomento

Make the goal buffer length 30s

Expose the goal buffer length as a plugin "global" and bump its value up from 5 to 30s. Modifying the default value is not recommended. Update tests to succeed even if the goal buffer length is modified. For #63.
1 parent bf699e11
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
11 11
12 var 12 var
13 13
14 // the desired length of video to maintain in the buffer, in seconds
15 goalBufferLength = 5,
16
17 // a fudge factor to apply to advertised playlist bitrates to account for 14 // a fudge factor to apply to advertised playlist bitrates to account for
18 // temporary flucations in client bandwidth 15 // temporary flucations in client bandwidth
19 bandwidthVariance = 1.1, 16 bandwidthVariance = 1.1,
...@@ -370,7 +367,8 @@ var ...@@ -370,7 +367,8 @@ var
370 367
371 // if there is plenty of content in the buffer and we're not 368 // if there is plenty of content in the buffer and we're not
372 // seeking, relax for awhile 369 // seeking, relax for awhile
373 if (typeof offset !== 'number' && bufferedTime >= goalBufferLength) { 370 if (typeof offset !== 'number' &&
371 bufferedTime >= videojs.Hls.GOAL_BUFFER_LENGTH) {
374 return; 372 return;
375 } 373 }
376 374
...@@ -577,6 +575,9 @@ videojs.Hls = videojs.Flash.extend({ ...@@ -577,6 +575,9 @@ videojs.Hls = videojs.Flash.extend({
577 } 575 }
578 }); 576 });
579 577
578 // the desired length of video to maintain in the buffer, in seconds
579 videojs.Hls.GOAL_BUFFER_LENGTH = 30;
580
580 videojs.Hls.prototype.src = function(src) { 581 videojs.Hls.prototype.src = function(src) {
581 var 582 var
582 player = this.player(), 583 player = this.player(),
......
...@@ -631,15 +631,16 @@ test('selects the correct rendition by player dimensions', function() { ...@@ -631,15 +631,16 @@ test('selects the correct rendition by player dimensions', function() {
631 631
632 632
633 test('does not download the next segment if the buffer is full', function() { 633 test('does not download the next segment if the buffer is full', function() {
634 var currentTime = 15;
634 player.src({ 635 player.src({
635 src: 'manifest/media.m3u8', 636 src: 'manifest/media.m3u8',
636 type: 'application/vnd.apple.mpegurl' 637 type: 'application/vnd.apple.mpegurl'
637 }); 638 });
638 player.currentTime = function() { 639 player.currentTime = function() {
639 return 15; 640 return currentTime;
640 }; 641 };
641 player.buffered = function() { 642 player.buffered = function() {
642 return videojs.createTimeRange(0, 20); 643 return videojs.createTimeRange(0, currentTime + videojs.Hls.GOAL_BUFFER_LENGTH);
643 }; 644 };
644 player.hls.mediaSource.trigger({ 645 player.hls.mediaSource.trigger({
645 type: 'sourceopen' 646 type: 'sourceopen'
......