merge
This commit is contained in:
commit
a27ff78730
1 changed files with 55 additions and 46 deletions
|
@ -25,7 +25,9 @@ Ox.VideoElement = function(options, self) {
|
|||
|
||||
Ox.Log('Video', 'VIDEO ELEMENT OPTIONS', self.options);
|
||||
|
||||
self.currentPart = 0;
|
||||
self.items = [];
|
||||
self.loadedMetadata = false;
|
||||
self.paused = true;
|
||||
self.$video = $('<div>');
|
||||
|
||||
|
@ -72,46 +74,6 @@ Ox.VideoElement = function(options, self) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
function loadPage(page, callback) {
|
||||
Ox.Log('Video', 'VIDEO loadPage', page);
|
||||
//page = Ox.mod(page, self.numberOfPages);
|
||||
var loadedmetadata = 0,
|
||||
start = page * self.pageLength,
|
||||
stop = Math.min(start + self.pageLength, self.numberOfItems),
|
||||
pageLength = stop - start;
|
||||
if (!self.items[start]) {
|
||||
self.options.src([start, stop], function(data) {
|
||||
data.forEach(function(data, i) {
|
||||
self.items[start + i] = loadItem(data.parts, data.points, function(item) {
|
||||
if (++loadedmetadata == pageLength) {
|
||||
Ox.Log('Video', 'VIDEO page', page, 'loaded');
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Ox.Log('Video', 'PAGE IN CACHE');
|
||||
callback && callback();
|
||||
}
|
||||
}
|
||||
|
||||
function loadPages(callback) {
|
||||
var currentPage = self.currentPage,
|
||||
nextPage = Ox.mod(currentPage + 1, self.numberOfPages),
|
||||
previousPage = Ox.mod(currentPage - 1, self.numberOfPages);
|
||||
loadPage(currentPage, function() {
|
||||
if (nextPage != currentPage) {
|
||||
loadPage(nextPage, function() {
|
||||
if (previousPage != currentPage && previousPage != nextPage) {
|
||||
unloadPage(previousPage);
|
||||
}
|
||||
});
|
||||
}
|
||||
callback && callback();
|
||||
});
|
||||
}
|
||||
|
||||
function loadItem(src, points, callback) {
|
||||
src = Ox.isArray(src) ? src : [src];
|
||||
var item = {
|
||||
|
@ -161,6 +123,7 @@ Ox.VideoElement = function(options, self) {
|
|||
callback && callback();
|
||||
} else {
|
||||
setCurrentItem(0);
|
||||
self.loadedMetadata = true;
|
||||
that.triggerEvent('loadedmetadata');
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +168,46 @@ Ox.VideoElement = function(options, self) {
|
|||
return item;
|
||||
}
|
||||
|
||||
function loadPage(page, callback) {
|
||||
Ox.Log('Video', 'VIDEO loadPage', page);
|
||||
//page = Ox.mod(page, self.numberOfPages);
|
||||
var loadedmetadata = 0,
|
||||
start = page * self.pageLength,
|
||||
stop = Math.min(start + self.pageLength, self.numberOfItems),
|
||||
pageLength = stop - start;
|
||||
if (!self.items[start]) {
|
||||
self.options.src([start, stop], function(data) {
|
||||
data.forEach(function(data, i) {
|
||||
self.items[start + i] = loadItem(data.parts, data.points, function(item) {
|
||||
if (++loadedmetadata == pageLength) {
|
||||
Ox.Log('Video', 'VIDEO page', page, 'loaded');
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Ox.Log('Video', 'PAGE IN CACHE');
|
||||
callback && callback();
|
||||
}
|
||||
}
|
||||
|
||||
function loadPages(callback) {
|
||||
var currentPage = self.currentPage,
|
||||
nextPage = Ox.mod(currentPage + 1, self.numberOfPages),
|
||||
previousPage = Ox.mod(currentPage - 1, self.numberOfPages);
|
||||
loadPage(currentPage, function() {
|
||||
if (nextPage != currentPage) {
|
||||
loadPage(nextPage, function() {
|
||||
if (previousPage != currentPage && previousPage != nextPage) {
|
||||
unloadPage(previousPage);
|
||||
}
|
||||
});
|
||||
}
|
||||
callback && callback();
|
||||
});
|
||||
}
|
||||
|
||||
function setCurrentItem(item) {
|
||||
Ox.Log('Video', 'scI', item);
|
||||
var interval;
|
||||
|
@ -426,12 +429,18 @@ Ox.VideoElement = function(options, self) {
|
|||
ret = self.video.src;
|
||||
} else {
|
||||
self.options.src = Ox.isArray(arguments[0]) ? arguments[0] : [arguments[0]];
|
||||
self.$video[self.currentPart].src = self.options.src[self.currentPart];
|
||||
self.$video.each(function(video, i) {
|
||||
if (i != self.currentPart) {
|
||||
video.src = self.options.src[i];
|
||||
}
|
||||
});
|
||||
if (self.loadedMetadata) {
|
||||
self.$video[self.currentPart].src = self.options.src[self.currentPart];
|
||||
self.$video.each(function(video, i) {
|
||||
if (i != self.currentPart) {
|
||||
video.src = self.options.src[i];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Ox.forEach(self.items[0].$videos, function($video, i) {
|
||||
$video[0].src = self.options.src[i] + '?' + Ox.uid();
|
||||
});
|
||||
}
|
||||
ret = that;
|
||||
}
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue