fix and optimize video preview

This commit is contained in:
rolux 2012-01-30 20:48:04 +00:00
parent 52b524430c
commit 8c5bbfd716
3 changed files with 12 additions and 6 deletions

View file

@ -1,4 +1,5 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.UI = (function() { pandora.UI = (function() {
var self = {}, that = {}; var self = {}, that = {};
@ -94,7 +95,7 @@ pandora.UI = (function() {
// (but don't trigger an additional event) // (but don't trigger an additional event)
add.listSelection = []; add.listSelection = [];
} else if (['text', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1) { } else if (['text', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1) {
// when switchin to a non-clip view, with a sort key // when switching to a non-clip view, with a sort key
// that only exists in clip view, reset sort to default // that only exists in clip view, reset sort to default
args.listSort = pandora.site.user.ui.listSort; args.listSort = pandora.site.user.ui.listSort;
} }
@ -149,6 +150,7 @@ pandora.UI = (function() {
} }
} }
// items in args trigger events, items in add do not
[args, add].forEach(function(obj, isAdd) { [args, add].forEach(function(obj, isAdd) {
Ox.forEach(obj, function(val, key) { Ox.forEach(obj, function(val, key) {
Ox.Log('', 'key/val', key, val) Ox.Log('', 'key/val', key, val)
@ -186,6 +188,7 @@ pandora.UI = (function() {
pandora.URL.update(Object.keys( pandora.URL.update(Object.keys(
!pandora.$ui.appPanel ? args : trigger !pandora.$ui.appPanel ? args : trigger
)); ));
}; };
return that; return that;

View file

@ -1004,13 +1004,13 @@ pandora.resizeWindow = function() {
} else if (pandora.user.ui.itemView == 'clips') { } else if (pandora.user.ui.itemView == 'clips') {
pandora.$ui.clipList.size(); pandora.$ui.clipList.size();
} else if (pandora.user.ui.itemView == 'video') { } else if (pandora.user.ui.itemView == 'video') {
pandora.$ui.player.options({ pandora.$ui.player && pandora.$ui.player.options({
// fixme: duplicated // fixme: duplicated
height: pandora.$ui.contentPanel.size(1), height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}); });
} else if (pandora.user.ui.itemView == 'timeline') { } else if (pandora.user.ui.itemView == 'timeline') {
pandora.$ui.editor.options({ pandora.$ui.editor && pandora.$ui.editor.options({
// fixme: duplicated // fixme: duplicated
height: pandora.$ui.contentPanel.size(1), height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1

View file

@ -6,9 +6,12 @@ pandora.ui.videoPreview = function(data) {
var that = Ox.VideoPreview({ var that = Ox.VideoPreview({
duration: data.duration, duration: data.duration,
getFrame: function(position) { getFrame: function(position) {
var resolution = Ox.filter(pandora.site.video.resolutions, function(resolution, i) { var resolutions = Ox.filter(pandora.site.video.resolutions, function(resolution, i) {
return resolution >= data.height || i == pandora.site.video.resolutions.length - 1; return resolution >= data.height;
})[0]; }),
resolution = resolutions.length
? Math.min(resolutions)
: Math.max(pandora.site.video.resolutions);
return '/' + data.id + '/' + resolution + 'p' + ( return '/' + data.id + '/' + resolution + 'p' + (
Ox.isUndefined(position) ? '' : position Ox.isUndefined(position) ? '' : position
) + '.jpg'; ) + '.jpg';