ae1590c7 by Brandon Bay Committed by David LaPalomento

Respect the preload-none option

Don’t start downloading segments if preload is set to “none”
1 parent 5c4a7c05
......@@ -143,9 +143,6 @@ videojs.Hls.prototype.src = function(src) {
setupEvents = function() {
this.fillBuffer();
player.trigger('loadedmetadata');
};
......@@ -558,6 +555,11 @@ videojs.Hls.prototype.fillBuffer = function(offset) {
segment,
segmentUri;
// if preload is set to "none", do not download segments until playback is requested
if (!player.hasClass('vjs-has-started') && player.options.preload === "none") {
return;
}
// if a video has not been specified, do nothing
if (!player.currentSrc() || !this.playlists) {
return;
......
......@@ -2299,4 +2299,29 @@ test('live stream should not call endOfStream', function(){
"media source should be in open state, not ended state for live stream after the last segment in m3u8 downloaded");
});
test('does not download segments if preload option set to none', function() {
var loadedSegments = 0;
player.src({
src: 'master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
player.options.preload = "none";
player.hls.loadSegment = function () {
loadedSegments++;
};
player.currentSrc = function() {
return player.src;
};
openMediaSource(player);
standardXHRResponse(requests.shift()); // master
standardXHRResponse(requests.shift()); // media
player.hls.checkBuffer_();
strictEqual(loadedSegments, 0, 'did not download any segments');
});
})(window, window.videojs);
......