diff --git a/static/js/uploadVideoDialog.js b/static/js/uploadVideoDialog.js index 1014facf..f7bb66fb 100644 --- a/static/js/uploadVideoDialog.js +++ b/static/js/uploadVideoDialog.js @@ -61,13 +61,36 @@ pandora.ui.uploadVideoDialog = function(data) { title: Ox._('Select Video'), maxFiles: 1, width: 96 + }).css({ + float: 'left' }).bindEvent({ click: function(data) { if (data.files.length) { cancelled = false; - $actionButton.hide(); - $closeButton.options('title', Ox._('Cancel')); - upload(data.files[0]); + $actionButton.replaceWith($actionButton = Ox.Button({ + id: 'action', + title: 'Upload', + disabled: true + }).css({ + float: 'left' + })); + getInfo(data.files[0], function(info) { + console.log(info); + $actionButton.options({ + disabled: false + }).bindEvent({ + click: function() { + info.direct ? directUpload(data.files[0], info) : upload(data.files[0]); + } + }); + $info.html(formatVideoInfo(info)); + $status.html( + info.direct + ? Ox._('Your video will be used directly.') + : Ox._('Your video will be transcoded.') + ); + }); + //$closeButton.options('title', Ox._('Cancel')); } } }) @@ -132,6 +155,17 @@ pandora.ui.uploadVideoDialog = function(data) { $status.html(status || '').append($progress); } + function directUpload(file, info) { + resetProgress(); + pandora.api.addMedia({ + filename: info.name, + id: info.oshash, + item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item + }, function(result) { + uploadStream(result.data.item, info, file); + }); + } + function encode() { var filename = pandora.firefogg.sourceFilename, info = JSON.parse(pandora.firefogg.sourceInfo), @@ -168,6 +202,43 @@ pandora.ui.uploadVideoDialog = function(data) { }); } + function getInfo(file, callback) { + Ox.oshash(file, function(oshash) { + var $video = $('