From cabc68681a316fd6c97ff21a260ebb5ed4424225 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 12 Feb 2013 13:31:58 +0530 Subject: [PATCH] fix subtitles in embed player --- static/js/embed/pandora.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/static/js/embed/pandora.js b/static/js/embed/pandora.js index 5e3cf1076..24beb4b45 100755 --- a/static/js/embed/pandora.js +++ b/static/js/embed/pandora.js @@ -163,7 +163,10 @@ Ox.load('UI', { function getVideoOptions(data) { var canPlayClips = data.editable || pandora.site.capabilities.canPlayClips[pandora.user.level] >= data.rightslevel, canPlayVideo = data.editable || pandora.site.capabilities.canPlayVideo[pandora.user.level] >= data.rightslevel, - options = {}; + options = {}, + subtitlesLayer = pandora.site.layers.filter(function(layer) { + return layer.isSubtitles; + })[0]; options.censored = canPlayVideo ? [] : canPlayClips ? ( options.subtitles.length @@ -200,11 +203,14 @@ Ox.load('UI', { }); }); options.posterFrame = data.posterFrame; - options.subtitles = data.layers.subtitles - ? data.layers.subtitles.map(function(subtitle) { - return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; - }) - : []; + options.subtitles = subtitlesLayer ? data.layers[subtitlesLayer.id].map(function(subtitle) { + return { + id: subtitle.id, + 'in': subtitle['in'], + out: subtitle.out, + text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n') + }; + }) : []; options.video = {}; pandora.site.video.resolutions.forEach(function(resolution) { options.video[resolution] = Ox.range(data.parts).map(function(i) {