forked from 0x2620/pandora
getFileInfo should only fire once
This commit is contained in:
parent
0d61dcd4e0
commit
3ce0fbfb81
1 changed files with 18 additions and 9 deletions
|
@ -115,6 +115,7 @@ pandora.ui.addItemDialog = function(options) {
|
|||
}
|
||||
|
||||
function getFileInfo(file, callback) {
|
||||
var done = false;
|
||||
Ox.oshash(file, function(oshash) {
|
||||
var $video = $('<video>'),
|
||||
url = URL.createObjectURL(file),
|
||||
|
@ -128,9 +129,15 @@ pandora.ui.addItemDialog = function(options) {
|
|||
video: []
|
||||
};
|
||||
$video.one('error', function(event) {
|
||||
if (!done) {
|
||||
done = true;
|
||||
URL.revokeObjectURL(url);
|
||||
callback(info);
|
||||
}
|
||||
});
|
||||
$video.one('loadedmetadata', function(event) {
|
||||
if (!done) {
|
||||
done = true;
|
||||
info.duration = $video[0].duration;
|
||||
if ($video[0].videoHeight > 0) {
|
||||
info.width = $video[0].videoWidth;
|
||||
|
@ -139,7 +146,9 @@ pandora.ui.addItemDialog = function(options) {
|
|||
if (info.duration) {
|
||||
info.bitrate = info.size * 8 / info.duration / 1000;
|
||||
}
|
||||
URL.revokeObjectURL(url);
|
||||
callback(info);
|
||||
}
|
||||
});
|
||||
$video[0].src = url;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue