check if same item is in new items on update item, fire durationchanged fixes #1640
This commit is contained in:
parent
1b1fb49eb8
commit
538d45ce57
1 changed files with 26 additions and 7 deletions
|
@ -30,16 +30,28 @@ Ox.VideoElement = function(options, self) {
|
|||
items: function() {
|
||||
self.loadedMetadata = false;
|
||||
loadItems(function() {
|
||||
if (self.items.length != self.numberOfItems) {
|
||||
self.numberOfItems = self.items.lenth;
|
||||
if (self.currentItem > self.numberOfItems) {
|
||||
var update = true;
|
||||
self.numberOfItems = self.items.lenth;
|
||||
if (self.currentItem > self.numberOfItems) {
|
||||
self.currentItem = 0;
|
||||
}
|
||||
if (self.currentItemId != self.items[self.currentItem].id) {
|
||||
// check if current item is in new items
|
||||
self.items.some(function(item, i) {
|
||||
if (item.id == self.currentItemId) {
|
||||
self.currentItem = i;
|
||||
loadNextVideo();
|
||||
update = false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (update) {
|
||||
self.currentItem = 0;
|
||||
self.currentItemId = self.items[self.currentItem].id;
|
||||
setCurrentVideo();
|
||||
}
|
||||
}
|
||||
var item = self.items[self.currentItem];
|
||||
if (self.$video.attr('src') != item.src) {
|
||||
setCurrentVideo();
|
||||
}
|
||||
that.triggerEvent('durationchanged');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -140,6 +152,10 @@ Ox.VideoElement = function(options, self) {
|
|||
|
||||
next();
|
||||
|
||||
function getId(item) {
|
||||
return item.src + '/' + item['in'] + '-' + item.out;
|
||||
}
|
||||
|
||||
function next() {
|
||||
var item;
|
||||
if (i < items.length) {
|
||||
|
@ -155,6 +171,7 @@ Ox.VideoElement = function(options, self) {
|
|||
}
|
||||
console.log('add item', item);
|
||||
currentTime += item.duration;
|
||||
item.id = getId(item);
|
||||
i++;
|
||||
next()
|
||||
} else {
|
||||
|
@ -165,6 +182,7 @@ Ox.VideoElement = function(options, self) {
|
|||
item.out = item['in'] + item.duration;
|
||||
}
|
||||
currentTime += item.duration;
|
||||
item.id = getId(item);
|
||||
i++;
|
||||
next();
|
||||
});
|
||||
|
@ -223,6 +241,7 @@ Ox.VideoElement = function(options, self) {
|
|||
set();
|
||||
function set() {
|
||||
self.currentItem = item;
|
||||
self.currentItemId = self.items[self.currentItem].id;
|
||||
setCurrentVideo();
|
||||
onLoadedMetadata(self.$video, function() {
|
||||
that.triggerEvent('sizechange');
|
||||
|
|
Loading…
Reference in a new issue