make Ox.getVideoInfo more reliable on Chrome
This commit is contained in:
parent
3f4e8764f6
commit
e3d8b5d3b0
2 changed files with 8 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -41,17 +41,25 @@ Ox.getVideoInfo <f>
|
|||
callback <f> 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);
|
||||
|
|
Loading…
Reference in a new issue