set preload='none' if buffered beyond out point

This commit is contained in:
j 2014-02-12 15:29:35 +00:00
parent d9bdf4e9b9
commit ab17fc8496

View file

@ -84,6 +84,7 @@ Ox.VideoElement = function(options, self) {
self.paused = true;
self.seeking = false;
self.loading = true;
self.buffering = true;
self.$videos = [getVideo(), getVideo()];
self.$video = self.$videos[self.currentVideo];
self.video = self.$video[0];
@ -141,7 +142,18 @@ Ox.VideoElement = function(options, self) {
// metadata loaded in loadItems
},
progress: function() {
// not implemented
// stop buffering if buffered to end point
if (self.video == this && self.buffering) {
var item = self.items[self.currentItem];
Ox.range(self.video.buffered.length).forEach(function(i) {
if (self.video.buffered.start(i) <= item['in']
&& self.video.buffered.end(i) >= item.out) {
self.video.preload = 'none';
self.buffering = false;
}
});
}
},
seeking: function() {
//seeking event triggered in setCurrentTime
@ -232,6 +244,7 @@ Ox.VideoElement = function(options, self) {
}
});
nextVideo.src = next.src;
nextVideo.preload = 'auto';
}
function setCurrentItem(item) {
@ -290,10 +303,12 @@ Ox.VideoElement = function(options, self) {
if (self.$video.attr('src') != item.src) {
self.loadedMetadata && Ox.Log('Video', 'caching next item failed, reset src');
self.video.src = item.src;
self.video.preload = 'auto';
}
self.video.volume = volume;
self.video.muted = muted;
self.$video.css(css);
self.buffering = true;
Ox.Log('Video', 'sCV', self.video.src, item['in'],
self.video.currentTime, self.video.seeking);
isReady(self.$video, function(video) {