fix embed player(subtitles)

This commit is contained in:
j 2014-09-23 23:56:29 +02:00
parent 32a558c48d
commit 5bd0fde709

View file

@ -102,7 +102,7 @@ pandora.ui.embedPlayer = function() {
resolution: ui.videoResolution,
scaleToFill: ui.videoScale == 'fill',
showIconOnLoad: true,
subtitles: video.subtitles,
subtitles: getSubtitles(options),
timeline: options.playInToOut ? function(size, i) {
return pandora.getMediaURL('/' + options.item
+ '/timelineantialias'
@ -335,6 +335,20 @@ pandora.ui.embedPlayer = function() {
return Ox.$('<canvas>').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(/<br\/?>/g, '\n'),
tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)]
};
}) : []
}
function selectAnnotation(data) {
if (data.id) {
setPosition(Math.max(data['in'], options['in'] || 0));