Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): add getActiveCaptionText helper for VTTCues
Richie McIlroy185a0de46eb0
diff --git a/apps/web/app/s/[videoId]/_components/caption-cues.ts b/apps/web/app/s/[videoId]/_components/caption-cues.tsnew file mode 100644index 000000000..c6dfb5663--- /dev/null+++ b/apps/web/app/s/[videoId]/_components/caption-cues.ts@@ -0,0 +1,18 @@+export function getActiveCaptionText(+ activeCues: TextTrackCueList | null | undefined,+): string {+ if (!activeCues?.length) {+ return "";+ }++ let selectedCue: VTTCue | null = null;++ for (let index = 0; index < activeCues.length; index++) {+ const cue = activeCues.item(index) as VTTCue | null;+ if (cue && (!selectedCue || cue.startTime >= selectedCue.startTime)) {+ selectedCue = cue;+ }+ }++ return selectedCue?.text.replace(/<[^>]*>/g, "") ?? "";+}