mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Merge pull request #1049 from JustAMan/fix-ff-newline-subs
Fix newline breaks in SRT subtitles shown in Firefox
This commit is contained in:
commit
b44c8c0c52
@ -116,8 +116,9 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeTrackEventText(text) {
|
function normalizeTrackEventText(text, useHtml) {
|
||||||
return text.replace(/\\N/gi, '\n');
|
var result = text.replace(/\\N/gi, '\n').replace(/\r/gi, '');
|
||||||
|
return useHtml ? result.replace(/\n/gi, '<br>') : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTracks(elem, tracks, item, mediaSource) {
|
function setTracks(elem, tracks, item, mediaSource) {
|
||||||
@ -1209,7 +1210,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
|
|||||||
data.TrackEvents.forEach(function (trackEvent) {
|
data.TrackEvents.forEach(function (trackEvent) {
|
||||||
|
|
||||||
var trackCueObject = window.VTTCue || window.TextTrackCue;
|
var trackCueObject = window.VTTCue || window.TextTrackCue;
|
||||||
var cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text));
|
var cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text, false));
|
||||||
|
|
||||||
trackElement.addCue(cue);
|
trackElement.addCue(cue);
|
||||||
});
|
});
|
||||||
@ -1250,8 +1251,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTrackEvent && selectedTrackEvent.Text) {
|
if (selectedTrackEvent && selectedTrackEvent.Text) {
|
||||||
|
subtitleTextElement.innerHTML = normalizeTrackEventText(selectedTrackEvent.Text, true);
|
||||||
subtitleTextElement.innerHTML = normalizeTrackEventText(selectedTrackEvent.Text);
|
|
||||||
subtitleTextElement.classList.remove('hide');
|
subtitleTextElement.classList.remove('hide');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user