From 5d4442d2ffca4114d01e03fd51968810b3d41be6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 3 Feb 2015 18:51:11 +0000 Subject: [PATCH] upload webms as stream if they look like a stream --- static/js/uploadVideoDialog.js | 89 ++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) 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 = $('