From 9da1540653b5c61f2c27ff635066b42e42d82ca0 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 9 Feb 2014 06:06:43 +0000 Subject: [PATCH] move video GC workaround into VideoElement --- source/Ox.UI/js/Core/GarbageCollection.js | 3 --- source/Ox.UI/js/Video/VideoElement.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/Ox.UI/js/Core/GarbageCollection.js b/source/Ox.UI/js/Core/GarbageCollection.js index 13fa2580..b1b33281 100644 --- a/source/Ox.UI/js/Core/GarbageCollection.js +++ b/source/Ox.UI/js/Core/GarbageCollection.js @@ -20,9 +20,6 @@ Ox.GarbageCollection = (function() { Object.keys(Ox.UI.elements).forEach(function(id) { var $element = Ox.UI.elements[id]; if ($element && Ox.isUndefined($element.$element.data('oxid'))) { - //Chrome does not properly release resources, reset manually - //http://code.google.com/p/chromium/issues/detail?id=31014 - $element.find('video').attr({src: ''}); $element.remove(); delete Ox.UI.elements[id]; } diff --git a/source/Ox.UI/js/Video/VideoElement.js b/source/Ox.UI/js/Video/VideoElement.js index cd11c526..4dd28a9f 100644 --- a/source/Ox.UI/js/Video/VideoElement.js +++ b/source/Ox.UI/js/Video/VideoElement.js @@ -151,6 +151,7 @@ Ox.VideoElement = function(options, self) { } }, timeupdate: function() { + //fixme: use setInterval(...,30); to be more accurate if (self.video == this) { if (self.items[self.currentItem] && self.items[self.currentItem].out @@ -443,6 +444,16 @@ Ox.VideoElement = function(options, self) { return that; }; + that.superRemove = that.remove; + that.remove = function() { + //Chrome does not properly release resources, reset manually + //http://code.google.com/p/chromium/issues/detail?id=31014 + self.$videos.forEach(function($video) { + $video.attr({src: ''}); + }); + return that.superRemove.apply(that, arguments); + } + /*@ videoHeight get videoHeight @*/