diff --git a/source/Ox.UI/js/Video/VideoElement.js b/source/Ox.UI/js/Video/VideoElement.js index af228d0f..a5ec6fea 100644 --- a/source/Ox.UI/js/Video/VideoElement.js +++ b/source/Ox.UI/js/Video/VideoElement.js @@ -143,14 +143,6 @@ Ox.VideoElement = function(options, self) { progress: function() { // not implemented }, - seeked: function() { - if (self.video == this) { - if (self.loadedMetadata && self.seeking && !self.loading) { - that.triggerEvent('seeked'); - self.seeking = false; - } - } - }, seeking: function() { //seeking event triggered in setCurrentTime }, @@ -220,10 +212,12 @@ Ox.VideoElement = function(options, self) { next = self.items[nextItem], $nextVideo = self.$videos[Ox.mod(self.currentVideo + 1, self.$videos.length)], nextVideo = $nextVideo[0]; - nextVideo.src = next.src; - onLoadedMetadata($nextVideo, function() { - nextVideo.currentTime = next['in'] || 0; + $nextVideo.one('loadedmetadata', function() { + if (self.video != nextVideo) { + nextVideo.currentTime = next['in'] || 0; + } }); + nextVideo.src = next.src; } function onLoadedMetadata($video, callback) { @@ -263,6 +257,8 @@ Ox.VideoElement = function(options, self) { self.loadedMetadata = true; that.triggerEvent('loadedmetadata'); } + Ox.Log('Video', 'sCI', 'trigger itemchange', + self.items[self.currentItem]['in'], self.video.currentTime, self.video.seeking); that.triggerEvent('sizechange'); that.triggerEvent('itemchange', { item: self.currentItem @@ -298,20 +294,17 @@ Ox.VideoElement = function(options, self) { self.video.volume = volume; self.video.muted = muted; self.$video.css(css); - Ox.Log('Video', 'sCV', self.video.src, self.items[self.currentItem]['in'], + Ox.Log('Video', 'sCV', self.video.src, item['in'], self.video.currentTime, self.video.seeking); onLoadedMetadata(self.$video, function(video) { self.$video.one('seeked', function() { self.loading = false; !self.paused && self.video.play(); self.$video.show(); - if (self.seeking) { - that.triggerEvent('seeked'); - self.seeking = false; - } callback && callback(); loadNextVideo(); }); + Ox.Log('Video', 'sCV set in', video.src, item['in'] || 0, video.currentTime, video.seeking); video.currentTime = item['in'] || 0; }); } @@ -319,13 +312,17 @@ Ox.VideoElement = function(options, self) { function setCurrentItemTime(currentTime) { Ox.Log('Video', 'sCIT', currentTime, self.video.currentTime, 'delta', currentTime - self.video.currentTime); - if (currentTime != self.video.currentTime) { - onLoadedMetadata(self.$video, function(video) { + onLoadedMetadata(self.$video, function(video) { + if (self.video == video) { + if(self.seeking) { + self.$video.one('seeked', function() { + that.triggerEvent('seeked'); + self.seeking = false; + }); + } video.currentTime = currentTime; - }); - } else { - that.triggerEvent('seeked'); - } + } + }); } function setCurrentTime(time) {