5 changed files with 115 additions and 21 deletions
@ -0,0 +1,36 @@ |
|||
import van from 'vanjs-core' |
|||
export function VttPreview(url: string, vtt: string, captionDiv: HTMLDivElement) { |
|||
const {video, track, div, button} = van.tags |
|||
const overlay = div( |
|||
{ |
|||
class: 'overlay', |
|||
id: 'vttPreviewOverlay', |
|||
}, |
|||
div( |
|||
button( |
|||
{ |
|||
onclick: (e) => { |
|||
e.target.parentElement.parentElement.remove() |
|||
captionDiv.removeAttribute('inert') |
|||
}, |
|||
}, |
|||
'close' |
|||
), |
|||
video( |
|||
{ |
|||
src: url, |
|||
controls: true, |
|||
}, |
|||
track({ |
|||
kind: 'captions', |
|||
default: true, |
|||
srclang: 'en', |
|||
src: `data:text/vtt;base64,${btoa(vtt)}`, |
|||
}) |
|||
) |
|||
) |
|||
) |
|||
|
|||
captionDiv.setAttribute('inert', 'true') |
|||
van.add(document.body, overlay) |
|||
} |
Loading…
Reference in new issue