From 12def53bd0c2a70ddca238a2d816cd6ca5532177 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 7 Aug 2015 08:56:46 +0100 Subject: [PATCH 2/2] embedTimeline: fix subtitles --- static/js/embedPlayer.js | 16 +--------------- static/js/embedTimeline.js | 2 +- static/js/tv.js | 16 +--------------- static/js/utils.js | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/static/js/embedPlayer.js b/static/js/embedPlayer.js index 004dc94..69f82ec 100644 --- a/static/js/embedPlayer.js +++ b/static/js/embedPlayer.js @@ -40,7 +40,7 @@ pandora.ui.embedPlayer = function() { sizes = getSizes(); options.height = sizes.videoHeight; - video.subtitles = getSubtitles(video); + video.subtitles = pandora.getSubtitles(video); if (options.title) { $title = Ox.Element() @@ -339,20 +339,6 @@ pandora.ui.embedPlayer = function() { return Ox.$('').attr({width: width, height: height})[0].toDataURL(); } - function getSubtitles(options) { - return options.subtitlesLayer ? options.annotations.filter(function(layer) { - return layer.id == options.subtitlesLayer; - })[0].items.map(function(subtitle) { - return { - id: subtitle.id, - 'in': subtitle['in'], - out: subtitle.out, - text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n'), - tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)] - }; - }) : []; - } - function selectAnnotation(data) { if (data.id) { setPosition(Math.max(data['in'], options['in'] || 0)); diff --git a/static/js/embedTimeline.js b/static/js/embedTimeline.js index ac7467b..31d47ed 100644 --- a/static/js/embedTimeline.js +++ b/static/js/embedTimeline.js @@ -65,7 +65,7 @@ pandora.ui.embedTimeline = function() { position: options.position, resolution: Ox.min(pandora.site.video.resolutions), smallTimelineURL: pandora.getMediaURL('/' + ui.item + '/timeline16p.jpg'), - subtitles: video.subtitles, + subtitles: pandora.getSubtitles(video), timeline: ui.videoTimeline, timelines: pandora.site.timelines, video: video.video, diff --git a/static/js/tv.js b/static/js/tv.js index e612018..bc8d527 100644 --- a/static/js/tv.js +++ b/static/js/tv.js @@ -38,20 +38,6 @@ pandora.ui.tv = function() { }); } - function getSubtitles(options) { - return options.subtitlesLayer ? options.annotations.filter(function(layer) { - return layer.id == options.subtitlesLayer; - })[0].items.map(function(subtitle) { - return { - id: subtitle.id, - 'in': subtitle['in'], - out: subtitle.out, - text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n'), - tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)] - }; - }) : [] - } - function play() { var $loading = $('') .attr({src: Ox.UI.getImageURL('symbolLoadingAnimated')}) @@ -89,7 +75,7 @@ pandora.ui.tv = function() { position: result.data.position, resolution: pandora.user.ui.videoResolution, scaleToFill: pandora.user.ui.videoScale == 'fill', - subtitles: getSubtitles(videoOptions), + subtitles: pandora.getSubtitles(videoOptions), subtitlesDefaultTrack: Ox.getLanguageNameByCode(pandora.site.language), subtitlesLayer: videoOptions.subtitlesLayer, subtitlesOffset: pandora.user.ui.videoSubtitlesOffset, diff --git a/static/js/utils.js b/static/js/utils.js index ce2d0ca..1ab79c6 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1906,6 +1906,20 @@ pandora.getStatusText = function(data) { return parts.join(', '); }; +pandora.getSubtitles = function(video) { + return video.subtitlesLayer ? video.annotations.filter(function(layer) { + return layer.id == video.subtitlesLayer; + })[0].items.map(function(subtitle) { + return { + id: subtitle.id, + 'in': subtitle['in'], + out: subtitle.out, + text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n'), + tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)] + }; + }) : []; +}; + pandora.getSubtitlesLayer = function() { return pandora.site.layers.filter(function(layer) { return layer.isSubtitles; -- 2.4.3