2011-12-19 21:12:23 +00:00
|
|
|
// 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
|
|
|
|
}),
|
2011-12-24 06:07:23 +00:00
|
|
|
$player,
|
|
|
|
list = pandora.user.ui._list,
|
2012-02-19 12:58:49 +00:00
|
|
|
lists = [],
|
|
|
|
muted;
|
2011-12-24 06:07:23 +00:00
|
|
|
|
|
|
|
function getList(direction) {
|
|
|
|
lists.length == 0 && getLists();
|
|
|
|
var index = lists.indexOf(list);
|
|
|
|
return lists[
|
|
|
|
direction == -1
|
|
|
|
? (index == 0 ? lists.length - 1 : index - 1)
|
|
|
|
: (index == lists.length - 1 ? 0 : index + 1)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLists() {
|
|
|
|
var menu = pandora.$ui.mainMenu.options('menus')[2];
|
|
|
|
lists = [''];
|
|
|
|
Ox.loop(3, function(f) {
|
|
|
|
menu.items[f + 1].items.forEach(function(l) {
|
|
|
|
lists.push(l.id.substr(8));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2011-12-19 21:12:23 +00:00
|
|
|
|
|
|
|
function play() {
|
|
|
|
pandora.api.tv({
|
2011-12-24 06:07:23 +00:00
|
|
|
list: list
|
2011-12-19 21:12:23 +00:00
|
|
|
}, function(result) {
|
|
|
|
var videoOptions = pandora.getVideoOptions(result.data);
|
2011-12-20 13:08:30 +00:00
|
|
|
$player && $player.remove();
|
2011-12-19 21:12:23 +00:00
|
|
|
$player = Ox.VideoPlayer({
|
|
|
|
censored: videoOptions.censored,
|
2011-12-24 06:07:23 +00:00
|
|
|
controlsBottom: [
|
|
|
|
'zapPrevious', 'zapHome', 'zapNext',
|
|
|
|
'volume', 'scale', 'timeline', 'position', 'settings'
|
|
|
|
],
|
2012-04-19 10:29:57 +00:00
|
|
|
controlsTooltips: {
|
|
|
|
open: 'Open in ' + Ox.getObjectById(
|
|
|
|
pandora.site.itemViews, pandora.user.ui.videoView
|
|
|
|
).title + ' View',
|
|
|
|
},
|
2011-12-23 10:51:53 +00:00
|
|
|
controlsTop: ['close', 'title', 'open'],
|
2011-12-19 21:12:23 +00:00
|
|
|
duration: result.data.duration,
|
2011-12-22 15:48:48 +00:00
|
|
|
enableSubtitles: pandora.user.ui.videoSubtitles,
|
2011-12-19 21:12:23 +00:00
|
|
|
fullscreen: true,
|
|
|
|
logo: pandora.site.tv.showLogo ? '/static/png/logo256.png' : '',
|
2012-02-19 12:58:49 +00:00
|
|
|
muted: muted || pandora.user.ui.videoMuted,
|
2011-12-19 21:12:23 +00:00
|
|
|
position: result.data.position,
|
2011-12-20 13:08:30 +00:00
|
|
|
resolution: pandora.user.ui.videoResolution,
|
2011-12-19 21:12:23 +00:00
|
|
|
scaleToFill: pandora.user.ui.videoScale == 'fill',
|
|
|
|
subtitles: videoOptions.subtitles,
|
|
|
|
tooltips: true,
|
|
|
|
timeline: '/' + result.data.item + '/timeline16p.png',
|
|
|
|
title: pandora.site.site.name + ' — ' + (
|
2011-12-24 06:07:23 +00:00
|
|
|
list || 'All ' + pandora.site.itemName.plural
|
2011-12-19 21:12:23 +00:00
|
|
|
) + ' — '
|
|
|
|
+ result.data.title
|
2012-02-23 10:51:32 +00:00
|
|
|
+ (
|
|
|
|
result.data.director
|
|
|
|
? ' (' + result.data.director.join(', ') + ') '
|
|
|
|
: ''
|
|
|
|
) + result.data.year,
|
2011-12-19 21:12:23 +00:00
|
|
|
video: videoOptions.video,
|
|
|
|
volume: pandora.user.ui.videoVolume
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-12-20 13:08:30 +00:00
|
|
|
close: that.fadeOutScreen,
|
|
|
|
ended: play,
|
2011-12-22 15:48:48 +00:00
|
|
|
muted: function(data) {
|
2012-02-19 12:58:49 +00:00
|
|
|
Ox.print('!MUTED', !muted)
|
|
|
|
!muted && pandora.UI.set('videoMuted', data.muted);
|
2011-12-22 15:48:48 +00:00
|
|
|
},
|
2011-12-23 10:51:53 +00:00
|
|
|
open: function() {
|
2011-12-23 15:08:04 +00:00
|
|
|
var item = result.data.item,
|
|
|
|
position = $player.options('position'),
|
|
|
|
set = {
|
|
|
|
item: item,
|
|
|
|
itemView: pandora.user.ui.videoView,
|
|
|
|
page: ''
|
|
|
|
};
|
|
|
|
if (pandora.user.ui.videoPoints[item]) {
|
|
|
|
set['videoPoints.' + item + '.position'] = position;
|
|
|
|
} else {
|
|
|
|
set['videoPoints.' + item] = {
|
|
|
|
'in': 0, out: 0, position: position
|
|
|
|
};
|
|
|
|
}
|
2011-12-23 10:51:53 +00:00
|
|
|
pandora.UI.set(set);
|
|
|
|
},
|
2011-12-20 13:08:30 +00:00
|
|
|
resolution: function(data) {
|
|
|
|
pandora.UI.set('videoResolution', data.resolution);
|
2011-12-22 15:48:48 +00:00
|
|
|
},
|
|
|
|
scale: function(data) {
|
|
|
|
pandora.UI.set('videoScale', data.scale);
|
|
|
|
},
|
|
|
|
subtitles: function(data) {
|
|
|
|
pandora.UI.set('videoSubtitles', data.subtitles);
|
|
|
|
},
|
|
|
|
volume: function(data) {
|
|
|
|
pandora.UI.set('videoVolume', data.volume);
|
|
|
|
},
|
2011-12-24 06:07:23 +00:00
|
|
|
zap: function(data) {
|
|
|
|
if (!(data.direction == 0 && list == '')) {
|
|
|
|
list = data.direction == 0 ? '' : getList(data.direction);
|
|
|
|
play();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
key_enter: function() {
|
|
|
|
$player.triggerEvent('open');
|
|
|
|
},
|
|
|
|
key_escape: function() {
|
|
|
|
$player.triggerEvent('close');
|
|
|
|
},
|
|
|
|
key_left: function() {
|
|
|
|
$player.triggerEvent('zap', {direction: -1});
|
|
|
|
},
|
|
|
|
key_right: function() {
|
|
|
|
$player.triggerEvent('zap', {direction: 1});
|
|
|
|
},
|
|
|
|
key_up: function() {
|
|
|
|
$player.triggerEvent('zap', {direction: 0});
|
|
|
|
}
|
2011-12-19 21:12:23 +00:00
|
|
|
})
|
|
|
|
.appendTo(that);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
that.fadeInScreen = function() {
|
|
|
|
that.appendTo(Ox.UI.$body).animate({opacity: 1}, 500);
|
|
|
|
play();
|
2011-12-20 13:08:30 +00:00
|
|
|
return that;
|
2011-12-19 21:12:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
that.fadeOutScreen = function() {
|
2011-12-20 13:08:30 +00:00
|
|
|
that.animate({opacity: 0}, 500, function() {
|
|
|
|
that.remove();
|
|
|
|
});
|
|
|
|
pandora.UI.set('page', '');
|
|
|
|
return that;
|
2011-12-19 21:12:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
that.hideScreen = function() {
|
2011-12-20 13:08:30 +00:00
|
|
|
that.remove();
|
|
|
|
pandora.UI.set('page', '');
|
|
|
|
return that;
|
2011-12-19 21:12:23 +00:00
|
|
|
};
|
|
|
|
|
2012-02-19 12:58:49 +00:00
|
|
|
that.mute = function() {
|
|
|
|
muted = true;
|
|
|
|
$player && $player.options({muted: muted});
|
|
|
|
};
|
|
|
|
|
2011-12-19 21:12:23 +00:00
|
|
|
that.showScreen = function() {
|
|
|
|
that.css({opacity: 1}).appendTo(Ox.UI.$body);
|
|
|
|
play();
|
2011-12-20 13:08:30 +00:00
|
|
|
return that;
|
2011-12-19 21:12:23 +00:00
|
|
|
};
|
|
|
|
|
2012-02-19 12:58:49 +00:00
|
|
|
that.unmute = function() {
|
|
|
|
$player && $player.options({muted: pandora.user.ui.videoMuted});
|
|
|
|
muted = false;
|
|
|
|
};
|
|
|
|
|
2011-12-19 21:12:23 +00:00
|
|
|
return that;
|
|
|
|
|
2011-12-20 13:08:30 +00:00
|
|
|
}
|