From dbac45f7ac0f23d23dc670122e034191b4a85f42 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 16 Sep 2014 13:30:53 +0200 Subject: [PATCH] fix tv subtitles --- static/js/editor.js | 1 - static/js/tv.js | 16 +++++++++++++++- static/js/utils.js | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/static/js/editor.js b/static/js/editor.js index 08002674..3c7faebb 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -3,7 +3,6 @@ 'use strict'; pandora.ui.editor = function(data) { - var ui = pandora.user.ui, that = Ox.VideoAnnotationPanel({ diff --git a/static/js/tv.js b/static/js/tv.js index cefdac69..f35cf01a 100644 --- a/static/js/tv.js +++ b/static/js/tv.js @@ -38,6 +38,20 @@ 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')}) @@ -75,7 +89,7 @@ pandora.ui.tv = function() { position: result.data.position, resolution: pandora.user.ui.videoResolution, scaleToFill: pandora.user.ui.videoScale == 'fill', - subtitles: videoOptions.subtitles, + subtitles: getSubtitles(videoOptions), subtitlesDefaultTrack: Ox.getLanguageNameByCode(pandora.site.language), subtitlesLayer: videoOptions.subtitlesLayer, subtitlesTrack: Ox.getLanguageNameByCode(pandora.site.language), diff --git a/static/js/utils.js b/static/js/utils.js index a2c10783..581ed23b 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1741,7 +1741,7 @@ pandora.getSubtitlesLayer = function() { }).map(function(layer) { return layer.id; })[0]; -} +}; pandora.getMediaURL = function(url) { return pandora.site.site.mediaprefix + url;