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++;
|
i++;
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
Ox.Log('VIDEO', 'getVideoInfo', item.src);
|
|
||||||
Ox.getVideoInfo(item.src, function(info) {
|
Ox.getVideoInfo(item.src, function(info) {
|
||||||
item.duration = info.duration;
|
item.duration = info.duration;
|
||||||
if (!item.out) {
|
if (!item.out) {
|
||||||
|
|
|
@ -41,17 +41,25 @@ Ox.getVideoInfo <f>
|
||||||
callback <f> gets called with object containing duration, width, height
|
callback <f> gets called with object containing duration, width, height
|
||||||
@*/
|
@*/
|
||||||
Ox.getVideoInfo = Ox.queue(function(url, callback) {
|
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');
|
var video = document.createElement('video');
|
||||||
video.addEventListener('loadedmetadata', function(event) {
|
video.addEventListener('loadedmetadata', function(event) {
|
||||||
|
Ox.Log('VIDEO', 'getVideoInfo done', url);
|
||||||
var info = {
|
var info = {
|
||||||
duration: this.duration,
|
duration: this.duration,
|
||||||
widht: this.videoWidth,
|
widht: this.videoWidth,
|
||||||
height: this.videoHeight,
|
height: this.videoHeight,
|
||||||
};
|
};
|
||||||
this.src = '';
|
this.src = '';
|
||||||
|
Ox.$(video).remove();
|
||||||
video = null;
|
video = null;
|
||||||
callback(info);
|
callback(info);
|
||||||
});
|
});
|
||||||
video.preload = 'metadata';
|
video.preload = 'metadata';
|
||||||
video.src = url;
|
video.src = url;
|
||||||
|
video.style.display = 'none';
|
||||||
|
Ox.$body.append(video);
|
||||||
}, 4);
|
}, 4);
|
||||||
|
|
Loading…
Reference in a new issue