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