dont fail if no subtitles layer

This commit is contained in:
rlx 2011-08-17 22:18:17 +00:00
parent 1da1579d9e
commit 39a5219267

View file

@ -184,7 +184,7 @@ pandora.ui.item = function() {
size = size || 128; size = size || 128;
var ratio = data.aspectRatio, var ratio = data.aspectRatio,
width = size, width = size,
height = parseInt(size/ratio), height = Math.round(size / ratio),
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg'; url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
return { return {
height: height, height: height,
@ -227,8 +227,8 @@ pandora.ui.item = function() {
streams = {}; streams = {};
video.height = video.resolutions[0]; video.height = video.resolutions[0];
video.width = parseInt(video.height * video.aspectRatio / 2) * 2; video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
video.resolutions.forEach(function(profile) { video.resolutions.forEach(function(resolution) {
streams[profile] = video.baseUrl + '/' + profile + 'p.' + format; 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]});
@ -246,9 +246,9 @@ pandora.ui.item = function() {
scaleToFill: pandora.user.ui.videoScale == 'fill', scaleToFill: pandora.user.ui.videoScale == 'fill',
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showControls: pandora.user.ui.showControls, showControls: pandora.user.ui.showControls,
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};
}), }) : [],
timeline: '/' + pandora.user.ui.item + '/timeline16p.png', timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
video: streams, video: streams,
videoHeight: video.height, videoHeight: video.height,
@ -294,7 +294,7 @@ pandora.ui.item = function() {
video.height = video.resolutions[0]; video.height = video.resolutions[0];
video.width = parseInt(video.height * video.aspectRatio / 2) * 2; video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
video.resolutions.forEach(function(profile) { video.resolutions.forEach(function(profile) {
streams[profile] = video.baseUrl + '/' + profile + 'p.' + format; 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]});
@ -323,9 +323,9 @@ pandora.ui.item = function() {
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true, showLargeTimeline: true,
// fixme: layers have value, subtitles has text? // fixme: layers have value, subtitles has text?
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: streams,
videoHeight: video.height, videoHeight: video.height,
//videoId: pandora.user.ui.item, //videoId: pandora.user.ui.item,