Captions for uploaded videos (migration 066)
Video blocks get a Captions field and the hero a Video captions field, each a WebVTT upload drawn as <track kind="captions" default> on a video file. The media library takes .vtt (sniffed by its WEBVTT header, kept as is, always in /uploads/captions/) with its own tab. Newsletter parts leave the field out. nginx needs text/vtt in mime.types: docs/media-uploads.md, step 5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
aaab1a945c
commit
33be618331
18 changed files with 123 additions and 43 deletions
|
|
@ -107,7 +107,7 @@ const sourceOf = (part: NewsletterPart): PickSource => (SOURCES.includes(part.so
|
|||
|
||||
/* Every part is a row: one editor for blocks and the email's own
|
||||
parts, so any of them can be moved, copied or removed. */
|
||||
const blockFields = blocksChild.fields.filter((field) => !['slot', 'team_id', 'type'].includes(field.path))
|
||||
const blockFields = blocksChild.fields.filter((field) => !['slot', 'team_id', 'type', 'captions'].includes(field.path))
|
||||
const PARTS_SPEC = {
|
||||
key: 'parts',
|
||||
label: 'Parts',
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
|
|||
|
||||
{feature === 'video' && hero?.video && (
|
||||
<div className="lg:col-span-7">
|
||||
<VideoFrame source={video} url={hero.video.url} title={hero.video.title} />
|
||||
<VideoFrame source={video} url={hero.video.url} title={hero.video.title} captions={mediaUrl(hero.video.captions)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
@ -498,10 +498,13 @@ function VideoFrame({
|
|||
source,
|
||||
url,
|
||||
title,
|
||||
captions,
|
||||
}: {
|
||||
source: VideoSource | null
|
||||
url: string
|
||||
title?: string | null
|
||||
/** A WebVTT file's URL; only a file plays it, an embed has its own. */
|
||||
captions?: string | null
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
|
|
@ -517,7 +520,9 @@ function VideoFrame({
|
|||
controls
|
||||
playsInline
|
||||
preload="metadata"
|
||||
/>
|
||||
>
|
||||
{captions && <track kind="captions" src={captions} srcLang="en" label="Captions" default />}
|
||||
</video>
|
||||
) : source?.kind === 'embed' ? (
|
||||
<VideoPlayer url={url} title={title || 'Featured video'} className="h-full" />
|
||||
) : (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue