use serialForEach to loadItems

This commit is contained in:
j 2014-02-09 05:31:15 +00:00
parent b2426c1ac6
commit 96cbf49579

View file

@ -168,20 +168,13 @@ Ox.VideoElement = function(options, self) {
}
function loadItems(callback) {
var currentTime = 0, i = 0,
var currentTime = 0,
items = self.options.items.map(function(item) {
return Ox.isObject(item) ? Ox.clone(item, true) : {src: item};
});
next();
function getId(item) {
return item.id || item.src + '/' + item['in'] + '-' + item.out;
}
function next() {
var item;
if (i < items.length) {
item = items[i];
Ox.serialForEach(items,
function(item) {
var callback = Ox.last(arguments);
item['in'] = item['in'] || 0;
item.position = currentTime;
if (item.out) {
@ -193,8 +186,7 @@ Ox.VideoElement = function(options, self) {
}
currentTime += item.duration;
item.id = getId(item);
i++;
next()
callback()
} else {
Ox.getVideoInfo(item.src, function(info) {
item.duration = info.duration;
@ -203,15 +195,18 @@ Ox.VideoElement = function(options, self) {
}
currentTime += item.duration;
item.id = getId(item);
i++;
next();
callback();
});
}
} else {
},
function() {
self.items = items;
self.numberOfItems = self.items.length;
callback && callback();
}
);
function getId(item) {
return item.id || item.src + '/' + item['in'] + '-' + item.out;
}
}