switch to new get api results
This commit is contained in:
parent
30a86de951
commit
09ee5fc417
10 changed files with 55 additions and 67 deletions
|
@ -549,5 +549,9 @@
|
|||
},
|
||||
"username": ""
|
||||
},
|
||||
"userLevels": ["guest", "member", "staff", "admin"]
|
||||
"userLevels": ["guest", "member", "staff", "admin"],
|
||||
"video": {
|
||||
"formats": ["webm", "h264"],
|
||||
"resolutions": [96]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,10 @@ class Annotation(models.Model):
|
|||
if key in j:
|
||||
_j[key] = j[key]
|
||||
j = _j
|
||||
if 'aspectRatio' in keys:
|
||||
j['aspectRatio'] = self.item.stream_aspect
|
||||
if 'videoRatio' in keys:
|
||||
streams = self.item.streams()
|
||||
if streams:
|
||||
j['videoRatio'] = streams[0].aspect_ratio
|
||||
if 'item' in keys:
|
||||
j['item'] = self.item.itemId
|
||||
return j
|
||||
|
|
|
@ -34,9 +34,6 @@ def site_config():
|
|||
site_config['site']['sectionName'] = settings.SITENAME
|
||||
site_config['site']['url'] = settings.URL
|
||||
|
||||
site_config['formats'] = settings.VIDEO_FORMATS
|
||||
site_config['resolutions'] = settings.VIDEO_RESOLUTIONS
|
||||
|
||||
site_config['keys'] = {}
|
||||
for key in site_config['itemKeys']:
|
||||
site_config['keys'][key['id']] = key
|
||||
|
|
|
@ -444,5 +444,9 @@
|
|||
},
|
||||
"username": ""
|
||||
},
|
||||
"userLevels": ["guest", "member", "staff", "admin"]
|
||||
"userLevels": ["guest", "member", "staff", "admin"],
|
||||
"video": {
|
||||
"formats": ["webm", "h264"],
|
||||
"resolutions": [480, 240, 96]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ Ox.load('Geo', function() {
|
|||
$.extend(pandora.user, {
|
||||
infoRatio: 16 / 9,
|
||||
sectionElement: 'buttons',
|
||||
selectedMovies: []
|
||||
selectedMovies: [],
|
||||
videoFormat: Ox.UI.getVideoFormat(pandora.site.video.formats)
|
||||
});
|
||||
// fixme: this should not happen
|
||||
if (!pandora.user.ui.lists[pandora.user.ui.list]) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.ui.info = function(id) {
|
||||
id = id || pandora.user.ui.item;
|
||||
Ox.print('ID', id)
|
||||
var that = Ox.Element()
|
||||
.bindEvent({
|
||||
toggle: function(data) {
|
||||
|
@ -32,13 +31,13 @@ pandora.ui.info = function(id) {
|
|||
});
|
||||
} else {
|
||||
// Video Preview
|
||||
pandora.api.get({id: id, keys: ['stream']}, function(result) {
|
||||
var video = result.data.stream;
|
||||
height = Math.round(pandora.user.ui.sidebarSize / video.aspectRatio) + 16;
|
||||
pandora.api.get({id: id, keys: ['duration', 'videoRatio']}, function(result) {
|
||||
var height = Math.round(pandora.user.ui.sidebarSize / result.data.videoRatio) + 16;
|
||||
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
|
||||
pandora.$ui.videoPreview = pandora.ui.videoPreview({
|
||||
id: id,
|
||||
video: video
|
||||
duration: result.data.duration,
|
||||
ratio: result.data.videoRatio
|
||||
}).appendTo(pandora.$ui.info);
|
||||
pandora.user.infoRatio = pandora.user.ui.sidebarSize / height;
|
||||
resize(height);
|
||||
|
|
|
@ -501,7 +501,7 @@ pandora.ui.infoView = function(data) {
|
|||
$reflectionIcon.attr({src: src});
|
||||
iconSize = iconSize == 256 ? 512 : 256;
|
||||
iconRatio = pandora.user.ui.icons == 'posters'
|
||||
? data.posterRatio : 1;
|
||||
? data.poster.width / data.poster.height : 1;
|
||||
toggleIconSize();
|
||||
pandora.user.level == 'admin' && $list.replaceWith($list = renderList());
|
||||
};
|
||||
|
@ -514,4 +514,4 @@ pandora.ui.infoView = function(data) {
|
|||
|
||||
return that;
|
||||
|
||||
}
|
||||
}
|
|
@ -116,18 +116,6 @@ pandora.ui.item = function() {
|
|||
}
|
||||
})
|
||||
);
|
||||
/*
|
||||
$.get('/static/html/itemInfo.html', {}, function(template) {
|
||||
//Ox.print(template);
|
||||
var posterRatio = result.data.posterRatio;
|
||||
result.data.posterWidth = posterRatio > 1 ? 256 : Math.round(256 * posterRatio);
|
||||
result.data.posterHeight = posterRatio < 1 ? 256 : Math.round(256 / posterRatio);
|
||||
result.data.posterLeft = Math.floor((256 - result.data.posterWidth) / 2);
|
||||
pandora.$ui.contentPanel.replaceElement(1,
|
||||
pandora.$ui.item = Ox.Element().append($.tmpl(template, result.data))
|
||||
);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'map') {
|
||||
|
@ -221,21 +209,20 @@ pandora.ui.item = function() {
|
|||
} else if (pandora.user.ui.itemView == 'player') {
|
||||
// fixme: duplicated
|
||||
var layers = [],
|
||||
video = result.data.stream,
|
||||
cuts = result.data.cuts || [],
|
||||
format = $.support.video.supportedFormat(pandora.site.formats),
|
||||
streams = {};
|
||||
video.height = pandora.site.resolutions[0];
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
pandora.site.resolutions.forEach(function(resolution) {
|
||||
streams[resolution] = video.baseUrl + '/' + resolution + 'p.' + format;
|
||||
});
|
||||
video = {};
|
||||
$.each(pandora.site.layers, function(i, layer) {
|
||||
layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]});
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
});
|
||||
//
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: video.duration,
|
||||
getTimelineImageURL: function(i) {
|
||||
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
||||
|
@ -250,10 +237,7 @@ pandora.ui.item = function() {
|
|||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
|
||||
video: streams,
|
||||
videoHeight: video.height,
|
||||
//videoId: pandora.user.ui.item,
|
||||
videoWidth: video.width,
|
||||
video: video,
|
||||
volume: pandora.user.ui.videoVolume,
|
||||
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
|
||||
}).bindEvent({
|
||||
|
@ -287,25 +271,23 @@ pandora.ui.item = function() {
|
|||
|
||||
} else if (pandora.user.ui.itemView == 'timeline') {
|
||||
var layers = [],
|
||||
video = result.data.stream,
|
||||
cuts = result.data.cuts || [],
|
||||
format = $.support.video.supportedFormat(pandora.site.formats),
|
||||
streams = {};
|
||||
video.height = pandora.site.resolutions[0];
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
pandora.site.resolutions.forEach(function(resolution) {
|
||||
streams[resolution] = video.baseUrl + '/' + resolution + 'p.' + format;
|
||||
});
|
||||
video = result.data.stream;
|
||||
$.each(pandora.site.layers, function(i, layer) {
|
||||
layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]});
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
});
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: cuts,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: video.duration,
|
||||
find: '',
|
||||
getFrameURL: function(position) {
|
||||
return '/' + pandora.user.ui.item + '/' + video.height.toString() + 'p' + position.toString() + '.jpg';
|
||||
return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg';
|
||||
},
|
||||
getLargeTimelineImageURL: function(i) {
|
||||
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
||||
|
@ -326,10 +308,8 @@ pandora.ui.item = function() {
|
|||
subtitles: result.data.layers.subtitles ? result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
video: streams,
|
||||
videoHeight: video.height,
|
||||
//videoId: pandora.user.ui.item,
|
||||
videoWidth: video.width,
|
||||
video: video,
|
||||
videoRatio: result.data.videoRatio,
|
||||
videoSize: pandora.user.ui.videoSize,
|
||||
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
|
||||
}).bindEvent({
|
||||
|
|
|
@ -168,8 +168,9 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
that = Ox.IconList({
|
||||
fixedRatio: fixedRatio,
|
||||
item: function(data, sort, size) {
|
||||
Ox.print('DATA', data)
|
||||
size = size || 128;
|
||||
var ratio = data.aspectRatio,
|
||||
var ratio = data.videoRatio,
|
||||
width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio),
|
||||
height = Math.round(width / ratio),
|
||||
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
||||
|
@ -196,7 +197,7 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
itemQuery: itemQuery
|
||||
}), callback);
|
||||
},
|
||||
keys: ['id', 'value', 'in', 'out', 'aspectRatio', 'item'],
|
||||
keys: ['id', 'value', 'in', 'out', 'video', 'videoRatio', 'item'],
|
||||
max: 1,
|
||||
size: 128,
|
||||
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
||||
|
@ -310,10 +311,10 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
element: pandora.$ui.clips = Ox.IconList({
|
||||
fixedRatio: fixedRatio,
|
||||
item: function(data, sort, size) {
|
||||
Ox.print('RATIO', data.aspectRatio);
|
||||
Ox.print('RATIO', data.videoRatio);
|
||||
size = size || 128;
|
||||
var width = data.aspectRatio < fixedRatio ? size : size * data.aspectRatio / fixedRatio,
|
||||
height = width / data.aspectRatio,
|
||||
var width = data.videoRatio < fixedRatio ? size : size * data.videoRatio / fixedRatio,
|
||||
height = width / data.videoRatio,
|
||||
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
||||
return {
|
||||
height: height,
|
||||
|
@ -326,7 +327,7 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
};
|
||||
},
|
||||
items: [],
|
||||
keys: ['id', 'value', 'in', 'out', 'aspectRatio', 'item'],
|
||||
keys: ['id', 'value', 'in', 'out', 'videoRatio', 'item'],
|
||||
size: 128,
|
||||
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
||||
unique: 'id'
|
||||
|
@ -454,8 +455,8 @@ pandora.ui.list = function() { // fixme: remove view argument
|
|||
}
|
||||
}, function(result) {
|
||||
var item = result.data.items[0],
|
||||
title = item.title + ' (' + item.director + ')',
|
||||
ratio = item.posterRatio,
|
||||
title = item.title + ' (' + item.director + ')'
|
||||
ratio = item.poster.width / item.poster.height,
|
||||
windowWidth = window.innerWidth * 0.8,
|
||||
windowHeight = window.innerHeight * 0.8,
|
||||
windowRatio = windowWidth / windowHeight,
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
pandora.ui.videoPreview = function(data) {
|
||||
var frameWidth = pandora.user.ui.sidebarSize,
|
||||
frameHeight = Math.round(frameWidth / data.video.aspectRatio),
|
||||
frameHeight = Math.round(frameWidth / data.ratio),
|
||||
that = Ox.VideoPreview({
|
||||
duration: data.video.duration,
|
||||
duration: data.duration,
|
||||
getFrame: function(position) {
|
||||
var width = pandora.user.ui.sidebarSize,
|
||||
height = Math.round(width / pandora.user.infoRatio),
|
||||
resolution = Ox.filter(pandora.site.resolutions, function(resolution, i) {
|
||||
return resolution >= height || i == pandora.site.resolutions.length - 1;
|
||||
resolution = Ox.filter(pandora.site.video.resolutions, function(resolution, i) {
|
||||
return resolution >= height || i == pandora.site.video.resolutions.length - 1;
|
||||
})[0];
|
||||
return '/' + data.id + '/' + resolution + 'p' + (
|
||||
Ox.isUndefined(position) ? '' : position
|
||||
|
|
Loading…
Reference in a new issue