This commit is contained in:
rolux 2011-12-19 21:12:23 +00:00
commit d20923703c
8 changed files with 155 additions and 69 deletions

View file

@ -226,7 +226,7 @@ pandora.URL = (function() {
pages: [
'about', 'api', 'contact', 'faq', 'help', 'home', 'news',
'preferences', 'rights', 'signin', 'signout', 'signup',
'software', 'terms', 'tour'
'software', 'terms', 'tour', 'tv'
],
sortKeys: sortKeys,
spanType: spanType,

View file

@ -68,6 +68,10 @@ pandora.ui.appPanel = function() {
} else {
pandora.ui.accountSignoutDialog().open();
}
} else if (page == 'tv') {
pandora.$ui.tv = pandora.ui.tv()[
!pandora.$ui.appPanel ? 'showScreen' : 'fadeInScreen'
]();
}
}
return that;

View file

@ -39,47 +39,7 @@ pandora.ui.item = function() {
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
// fixme: layers have value, subtitles has text?
var subtitles = result.data.layers.subtitles
? result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
})
: [],
canPlayClips = pandora.site.capabilities.canPlayClips[pandora.user.level] >= result.data.rightslevel,
canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= result.data.rightslevel,
censored = canPlayVideo ? []
: canPlayClips ? (
subtitles.length
? Ox.merge(
subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : subtitles[i - 1].out,
out: subtitle['in']
};
}),
[{'in': Ox.last(subtitles).out, out: result.data.duration}]
)
: Ox.range(0, result.data.duration - 5, 60).map(function(position) {
return {
'in': position + 5,
out: Math.min(position + 60, result.data.duration)
};
})
)
: [{'in': 0, out: result.data.duration}],
layers = [],
video = {};
pandora.site.layers.forEach(function(layer, i) {
layers[i] = Ox.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) {
var part = (i + 1),
prefix = pandora.site.site.videoprefix.replace('PART', part);
return prefix + '/' + pandora.user.ui.item + '/'
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
});
});
var videoOptions = pandora.getVideoOptions(result.data);
}
if (!result.data.rendered && [
@ -160,7 +120,7 @@ pandora.ui.item = function() {
} else if (pandora.user.ui.itemView == 'video') {
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
annotationsSize: pandora.user.ui.annotationsSize,
censored: censored,
censored: videoOptions.censored,
cuts: result.data.cuts || [],
duration: result.data.duration,
find: pandora.user.ui.itemFind.conditions[0]
@ -176,10 +136,10 @@ pandora.ui.item = function() {
scaleToFill: pandora.user.ui.videoScale == 'fill',
showAnnotations: pandora.user.ui.showAnnotations,
showTimeline: pandora.user.ui.showTimeline,
subtitles: subtitles,
subtitles: videoOptions.subtitles,
tooltips: true,
timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
video: video,
video: videoOptions.video,
volume: pandora.user.ui.videoVolume,
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({

77
static/js/pandora/tv.js Normal file
View file

@ -0,0 +1,77 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.tv = function() {
var that = Ox.Element()
.addClass('OxScreen')
.css({
position: 'absolute',
width: '100%',
height: '100%',
opacity: 0,
zIndex: 1000
}),
$player;
function play() {
pandora.api.tv({
list: pandora.user.ui._list
}, function(result) {
var videoOptions = pandora.getVideoOptions(result.data);
$player && player.remove();
$player = Ox.VideoPlayer({
censored: videoOptions.censored,
controlsBottom: ['volume', 'scale', 'timeline', 'position', 'resolution'],
controlsTop: ['close', 'title'],
duration: result.data.duration,
fullscreen: true,
logo: pandora.site.tv.showLogo ? '/static/png/logo256.png' : '',
position: result.data.position,
scaleToFill: pandora.user.ui.videoScale == 'fill',
subtitles: videoOptions.subtitles,
tooltips: true,
timeline: '/' + result.data.item + '/timeline16p.png',
title: pandora.site.site.name + ' — ' + (
pandora.user.ui._list
? pandora.user.ui._list
: 'All ' + pandora.site.itemName.plural
) + ' — '
+ result.data.title
+ ' (' + result.data.director.join(', ') + ') '
+ result.data.year,
video: videoOptions.video,
volume: pandora.user.ui.videoVolume
})
.bindEvent({
close: function() {
},
ended: play
})
.appendTo(that);
});
}
that.fadeInScreen = function() {
that.appendTo(Ox.UI.$body).animate({opacity: 1}, 500);
play();
};
that.fadeOutScreen = function() {
};
that.hideScreen = function() {
};
that.showScreen = function() {
that.css({opacity: 1}).appendTo(Ox.UI.$body);
play();
};
return that;
}

View file

@ -722,6 +722,47 @@ pandora.getSortOperator = function(key) {
) > -1 ? '+' : '-';
};
pandora.getVideoOptions = function(data) {
var canPlayClips = pandora.site.capabilities.canPlayClips[pandora.user.level] >= data.rightslevel,
canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= data.rightslevel,
options = {};
options.subtitles = data.layers.subtitles
? data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
})
: [];
options.censored = canPlayVideo ? []
: canPlayClips ? (
options.subtitles.length
? Ox.merge(
options.subtitles.map(function(subtitle, i) {
return {
'in': i == 0 ? 0 : options.subtitles[i - 1].out,
out: subtitle['in']
};
}),
[{'in': Ox.last(options.subtitles).out, out: data.duration}]
)
: Ox.range(0, data.duration - 5, 60).map(function(position) {
return {
'in': position + 5,
out: Math.min(position + 60, data.duration)
};
})
)
: [{'in': 0, out: data.duration}];
options.video = {};
pandora.site.video.resolutions.forEach(function(resolution) {
options.video[resolution] = Ox.range(data.parts).map(function(i) {
var part = (i + 1),
prefix = pandora.site.site.videoprefix.replace('PART', part); // fixme: '{part}' would be more consistent
return prefix + '/' + (data.item || pandora.user.ui.item) + '/'
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
});
});
return options;
};
pandora.getVideoPartsAndPoints = function(durations, points) {
var parts = durations.length,
offsets = Ox.range(parts).map(function(i) {