forked from 0x2620/pandora
embedTimeline: fix subtitles (fixes #2823)
This commit is contained in:
parent
3da3bd37fd
commit
5418613023
4 changed files with 17 additions and 31 deletions
|
@ -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.$('<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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(/<br\/?>/g, '\n'),
|
||||
tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)]
|
||||
};
|
||||
}) : []
|
||||
}
|
||||
|
||||
function play() {
|
||||
var $loading = $('<img>')
|
||||
.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,
|
||||
|
|
|
@ -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(/<br\/?>/g, '\n'),
|
||||
tracks: subtitle.languages || [Ox.getLanguageNameByCode(pandora.site.language)]
|
||||
};
|
||||
}) : [];
|
||||
};
|
||||
|
||||
pandora.getSubtitlesLayer = function() {
|
||||
return pandora.site.layers.filter(function(layer) {
|
||||
return layer.isSubtitles;
|
||||
|
|
Loading…
Reference in a new issue