From 89e4368a0e598549b3708615fabed24f8950f447 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 9 Feb 2014 06:16:57 +0000 Subject: [PATCH] use setInterval instead of video.timeupdate, timeupdate does not fire often enough --- source/Ox.UI/js/Video/VideoElement.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/Ox.UI/js/Video/VideoElement.js b/source/Ox.UI/js/Video/VideoElement.js index 4dd28a9f..175998aa 100644 --- a/source/Ox.UI/js/Video/VideoElement.js +++ b/source/Ox.UI/js/Video/VideoElement.js @@ -94,6 +94,16 @@ Ox.VideoElement = function(options, self) { opacity: 0 }) .appendTo(that); + self.timeupdate = setInterval(function() { + if (!self.paused + && !self.loading + && self.loadedMetadata + && self.items[self.currentItem] + && self.items[self.currentItem].out + && self.video.currentTime >= self.items[self.currentItem].out) { + setCurrentItem(self.currentItem + 1); + } + }, 30); loadItems(function() { setCurrentItem(0); @@ -149,16 +159,6 @@ Ox.VideoElement = function(options, self) { self.video.pause(); that.triggerEvent('ended'); } - }, - timeupdate: function() { - //fixme: use setInterval(...,30); to be more accurate - if (self.video == this) { - if (self.items[self.currentItem] - && self.items[self.currentItem].out - && this.currentTime >= self.items[self.currentItem].out) { - setCurrentItem(self.currentItem + 1); - } - } } }) .attr({ @@ -446,6 +446,7 @@ Ox.VideoElement = function(options, self) { that.superRemove = that.remove; that.remove = function() { + clearInterval(self.timeupdate); //Chrome does not properly release resources, reset manually //http://code.google.com/p/chromium/issues/detail?id=31014 self.$videos.forEach(function($video) {