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 @@
var
// the desired length of video to maintain in the buffer, in seconds
goalBufferLength = 5,
// a fudge factor to apply to advertised playlist bitrates to account for
// temporary flucations in client bandwidth
bandwidthVariance = 1.1,
......@@ -370,7 +367,8 @@ var
// if there is plenty of content in the buffer and we're not
// seeking, relax for awhile
if (typeof offset !== 'number' && bufferedTime >= goalBufferLength) {
if (typeof offset !== 'number' &&
bufferedTime >= videojs.Hls.GOAL_BUFFER_LENGTH) {
return;
}
......@@ -577,6 +575,9 @@ videojs.Hls = videojs.Flash.extend({
}
});
// the desired length of video to maintain in the buffer, in seconds
videojs.Hls.GOAL_BUFFER_LENGTH = 30;
videojs.Hls.prototype.src = function(src) {
var
player = this.player(),
......
......@@ -631,15 +631,16 @@ test('selects the correct rendition by player dimensions', function() {
test('does not download the next segment if the buffer is full', function() {
var currentTime = 15;
player.src({
src: 'manifest/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
player.currentTime = function() {
return 15;
return currentTime;
};
player.buffered = function() {
return videojs.createTimeRange(0, 20);
return videojs.createTimeRange(0, currentTime + videojs.Hls.GOAL_BUFFER_LENGTH);
};
player.hls.mediaSource.trigger({
type: 'sourceopen'
......