fix updating items

This commit is contained in:
j 2013-07-13 23:06:07 +00:00
parent 8383643549
commit 2403cd269d

View file

@ -31,8 +31,7 @@ Ox.VideoElement = function(options, self) {
self.loadedMetadata = false; self.loadedMetadata = false;
loadItems(function() { loadItems(function() {
var update = true; var update = true;
self.numberOfItems = self.items.lenth; if (self.currentItem >= self.numberOfItems) {
if (self.currentItem > self.numberOfItems) {
self.currentItem = 0; self.currentItem = 0;
} }
if (self.currentItemId != self.items[self.currentItem].id) { if (self.currentItemId != self.items[self.currentItem].id) {
@ -51,7 +50,7 @@ Ox.VideoElement = function(options, self) {
setCurrentVideo(); setCurrentVideo();
} }
} }
that.triggerEvent('durationchanged'); that.triggerEvent('durationchange');
}); });
} }
}) })
@ -149,7 +148,6 @@ Ox.VideoElement = function(options, self) {
items = self.options.items.map(function(item) { items = self.options.items.map(function(item) {
return Ox.isObject(item) ? Ox.clone(item, true) : {src: item}; return Ox.isObject(item) ? Ox.clone(item, true) : {src: item};
}); });
next(); next();
function getId(item) { function getId(item) {
@ -169,7 +167,6 @@ Ox.VideoElement = function(options, self) {
if(!item.out) { if(!item.out) {
item.out = item.duration - item['in']; item.out = item.duration - item['in'];
} }
console.log('add item', item);
currentTime += item.duration; currentTime += item.duration;
item.id = getId(item); item.id = getId(item);
i++; i++;
@ -205,7 +202,6 @@ Ox.VideoElement = function(options, self) {
next = self.items[nextItem], next = self.items[nextItem],
$nextVideo = self.$videos[Ox.mod(self.currentVideo + 1, self.$videos.length)], $nextVideo = self.$videos[Ox.mod(self.currentVideo + 1, self.$videos.length)],
nextVideo = $nextVideo[0]; nextVideo = $nextVideo[0];
nextVideo.src = next.src; nextVideo.src = next.src;
onLoadedMetadata($nextVideo, function() { onLoadedMetadata($nextVideo, function() {
nextVideo.currentTime = next['in'] || 0; nextVideo.currentTime = next['in'] || 0;