diff --git a/source/Ox.UI/js/Video/VideoElement.js b/source/Ox.UI/js/Video/VideoElement.js index ca583d84..97f0e105 100644 --- a/source/Ox.UI/js/Video/VideoElement.js +++ b/source/Ox.UI/js/Video/VideoElement.js @@ -189,7 +189,6 @@ Ox.VideoElement = function(options, self) { i++; next() } else { - Ox.Log('VIDEO', 'getVideoInfo', item.src); Ox.getVideoInfo(item.src, function(info) { item.duration = info.duration; if (!item.out) { diff --git a/source/Ox/js/Video.js b/source/Ox/js/Video.js index b814878b..a8f2252a 100644 --- a/source/Ox/js/Video.js +++ b/source/Ox/js/Video.js @@ -41,17 +41,25 @@ Ox.getVideoInfo callback gets called with object containing duration, width, height @*/ Ox.getVideoInfo = Ox.queue(function(url, callback) { + // append video element to $body to work around a + // bug in Chrome where loadedmetadata is not fired + // reliably if video element is not in the DOM. + Ox.Log('VIDEO', 'getVideoInfo', url); var video = document.createElement('video'); video.addEventListener('loadedmetadata', function(event) { + Ox.Log('VIDEO', 'getVideoInfo done', url); var info = { duration: this.duration, widht: this.videoWidth, height: this.videoHeight, }; this.src = ''; + Ox.$(video).remove(); video = null; callback(info); }); video.preload = 'metadata'; video.src = url; + video.style.display = 'none'; + Ox.$body.append(video); }, 4);