mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-30 03:51:25 -08:00
fix(multiple-subtitles): render overlapping cues on legacy hosts [PKG-MULTI-SUB-10]
This commit is contained in:
1 parent
31f9024bff
commit
8ae2762a23
24 files changed
+3465
-56
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { CaptionHost } from './types'
|
||||
|
||||
export default function renderLegacyCaptions(art: CaptionHost): void {
|
||||
const cues = art.subtitle?.textTrack?.activeCues
|
||||
if (!cues || cues.length < 2)
|
||||
return
|
||||
|
||||
const texts = Array.from(cues, cue => 'text' in cue && typeof cue.text === 'string' ? cue.text : '')
|
||||
const target = art.template.$subtitle
|
||||
if (art.option?.subtitle?.escape) {
|
||||
target.innerHTML = ''
|
||||
for (const text of texts) {
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
const element = target.ownerDocument.createElement('div')
|
||||
element.className = 'art-subtitle-line'
|
||||
element.textContent = line
|
||||
target.appendChild(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.innerHTML = texts.join('')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user