From 8dfae53ae5cdc54effa1d8eedc8b3cf41ecfe137 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Wed, 18 Feb 2026 19:44:41 +1300 Subject: [PATCH] Improvements to Transcript and Captions --- materialious/src/lib/api/model.ts | 4 +- .../components/player/ClosedCaptions.svelte | 23 ++++---- .../lib/components/watch/Transcript.svelte | 55 +++++++++---------- materialious/src/lib/player/captions.ts | 25 +++++++++ .../routes/(app)/watch/[slug]/+page.svelte | 4 +- 5 files changed, 66 insertions(+), 45 deletions(-) create mode 100644 materialious/src/lib/player/captions.ts diff --git a/materialious/src/lib/api/model.ts b/materialious/src/lib/api/model.ts index 7902c11c..793e795c 100644 --- a/materialious/src/lib/api/model.ts +++ b/materialious/src/lib/api/model.ts @@ -98,6 +98,8 @@ export interface Ytjs { rawApiResponse: ApiResponse; } +export type FallbackPatches = 'youtubejs' | 'piped'; + export interface VideoPlay extends Video { keywords: string[]; likeCount: number; @@ -120,7 +122,7 @@ export interface VideoPlay extends Video { captions: Captions[]; storyboards?: StoryBoard[]; ytjs?: Ytjs; - fallbackPatch?: 'youtubejs' | 'piped'; + fallbackPatch?: FallbackPatches; } export interface StoryBoard { diff --git a/materialious/src/lib/components/player/ClosedCaptions.svelte b/materialious/src/lib/components/player/ClosedCaptions.svelte index 75f52ad6..9eff9dd3 100644 --- a/materialious/src/lib/components/player/ClosedCaptions.svelte +++ b/materialious/src/lib/components/player/ClosedCaptions.svelte @@ -48,11 +48,12 @@ {#if trackVisible && captionsCues.length > 0} - {#if currentCaption && currentTime <= currentCaption.endTime && currentTime >= currentCaption.startTime} + {#if currentCaption}
- {#if currentCaption?.text} + {#if currentCaption}

- {decodeHtmlCharCodes(currentCaption.text)} + + {@html renderVTTCueString(currentCaption, currentTime)}

{/if}
diff --git a/materialious/src/lib/components/watch/Transcript.svelte b/materialious/src/lib/components/watch/Transcript.svelte index 988f600f..5c8fd05c 100644 --- a/materialious/src/lib/components/watch/Transcript.svelte +++ b/materialious/src/lib/components/watch/Transcript.svelte @@ -1,31 +1,32 @@