From 7142095411020bcad272998bdb913caa286ee7ec Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 20 Feb 2013 11:28:51 +0530 Subject: [PATCH] add embedPlayer, update embedPanel --- static/js/pandora/embedPanel.js | 12 +++++- static/js/pandora/embedPlayer.js | 74 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 static/js/pandora/embedPlayer.js diff --git a/static/js/pandora/embedPanel.js b/static/js/pandora/embedPanel.js index d19a4ce9f..cfeaf10c2 100644 --- a/static/js/pandora/embedPanel.js +++ b/static/js/pandora/embedPanel.js @@ -4,7 +4,17 @@ pandora.ui.embedPanel = function() { if (pandora.user.ui.item) { - that = Ox.Element().html('OK'); + that = Ox.Element(); + + pandora.api.get({id: pandora.user.ui.item, keys: [ + 'duration', 'layers', 'parts', 'posterFrame', + 'rightslevel', 'size', 'title', 'videoRatio' + ]}, function(result) { + Ox.extend(result.data, pandora.getVideoOptions(result.data)); + that.setElement( + pandora.$ui.embedPlayer = pandora.ui.embedPlayer(result.data) + ); + }); } else { diff --git a/static/js/pandora/embedPlayer.js b/static/js/pandora/embedPlayer.js new file mode 100644 index 000000000..2296e6bce --- /dev/null +++ b/static/js/pandora/embedPlayer.js @@ -0,0 +1,74 @@ +pandora.ui.embedPlayer = function(data) { + + var options = getOptions(), + that = Ox.VideoPlayer(Ox.extend({ + censored: data.censored, + censoredIcon: pandora.site.cantPlay.icon, + censoredTooltip: pandora.site.cantPlay.text, + controlsBottom: ['play', 'volume', 'scale'].concat( + Ox.Fullscreen.available ? ['fullscreen'] : [] + ).concat( + ['timeline', 'position', 'settings'] + ), + controlsTooltips: { + close: 'Close', + open: 'Watch on ' + pandora.site.site.name + }, + controlsTop: (options.showCloseButton ? ['close'] : []).concat( + ['title', 'open'] + ), + duration: data.duration, + enableFullscreen: Ox.Fullscreen.available, + enableKeyboard: true, + enableMouse: true, + enablePosition: true, + enableSubtitles: true, + enableTimeline: true, + enableVolume: true, + height: options.height, + invertHighlight: options.invertHighlight, + paused: options.paused, + playInToOut: options.playInToOut, + position: options.position, + poster: '/' + options.item + '/' + '96p' + ( + options.position !== void 0 ? options.position + : options['in'] !== void 0 ? options['in'] + : data.posterFrame + ) +'.jpg', + resolution: pandora.user.ui.videoResolution, + subtitles: data.subtitles, + timeline: options.playInToOut ? function(size, i) { + return '/' + options.item + + '/timelineantialias' + + size + 'p' + i + '.jpg' + } : '/' + options.item + '/' + 'timeline16p.png', + title: result.data.title, + video: data.video, + width: options.width + }, options['in'] ? { + 'in': options['in'] + } : {}, options.out ? { + out: options.out + } : {})); + + function getOptions() { + var defaults = { + height: 144, + invertHighlight: true, + paused: true, + playInToOut: true, + width: 256 + }, + options = Ox.extend(defaults, pandora.user.ui.hash.query); + if (!options.position) { + options.position = options['in'] || 0; + } + if (!options['in'] && !options.out) { + options.playInToOut = false; + } + return options; + } + + return that; + +}; \ No newline at end of file