From cdbcef3020f45e136d7881aa9deef821105d6bd3 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 19 Jan 2024 18:57:35 +0100 Subject: [PATCH] fix: subtitles line breaks --- src/TizenVideo/TizenVideo.js | 4 +++- src/withHTMLSubtitles/withHTMLSubtitles.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TizenVideo/TizenVideo.js b/src/TizenVideo/TizenVideo.js index 224a4eb..dfca3af 100644 --- a/src/TizenVideo/TizenVideo.js +++ b/src/TizenVideo/TizenVideo.js @@ -43,6 +43,7 @@ function TizenVideo(options) { function renderSubtitle(duration, text) { if (disabledSubs) return; + // we ignore custom delay here, it's not needed for embedded subs lastSub = { duration: duration, @@ -60,9 +61,10 @@ function TizenVideo(options) { subtitlesElement.style.bottom = offset + '%'; var cueNode = document.createElement('span'); - cueNode.innerHTML = text; + cueNode.innerHTML = text.replaceAll('
', '\n'); cueNode.style.display = 'inline-block'; cueNode.style.padding = '0.2em'; + cueNode.style.whiteSpace = 'pre-wrap'; cueNode.style.fontSize = Math.floor(size / 25) + 'vmin'; cueNode.style.color = textColor; cueNode.style.backgroundColor = backgroundColor; diff --git a/src/withHTMLSubtitles/withHTMLSubtitles.js b/src/withHTMLSubtitles/withHTMLSubtitles.js index 4bdcaf1..ab2093d 100644 --- a/src/withHTMLSubtitles/withHTMLSubtitles.js +++ b/src/withHTMLSubtitles/withHTMLSubtitles.js @@ -77,6 +77,7 @@ function withHTMLSubtitles(Video) { subtitlesRenderer.render(cuesByTime, videoState.time + delay).forEach(function(cueNode) { cueNode.style.display = 'inline-block'; cueNode.style.padding = '0.2em'; + cueNode.style.whiteSpace = 'pre-wrap'; cueNode.style.fontSize = Math.floor(size / 25) + 'vmin'; cueNode.style.color = textColor; cueNode.style.backgroundColor = backgroundColor;