diff --git a/src/backend/helpers/streams.ts b/src/backend/helpers/streams.ts index aca41fe2..12cbc551 100644 --- a/src/backend/helpers/streams.ts +++ b/src/backend/helpers/streams.ts @@ -6,6 +6,7 @@ export enum MWStreamType { export enum MWCaptionType { VTT = "vtt", SRT = "srt", + UNKNOWN = "unknown", } export enum MWStreamQuality { @@ -20,7 +21,7 @@ export enum MWStreamQuality { export type MWCaption = { needsProxy?: boolean; url: string; - type?: MWCaptionType; + type: MWCaptionType; langIso: string; }; diff --git a/src/video/components/popouts/CaptionSelectionPopout.tsx b/src/video/components/popouts/CaptionSelectionPopout.tsx index b9201024..2ae9fced 100644 --- a/src/video/components/popouts/CaptionSelectionPopout.tsx +++ b/src/video/components/popouts/CaptionSelectionPopout.tsx @@ -3,7 +3,7 @@ import { parseSubtitles, subtitleTypeList, } from "@/backend/helpers/captions"; -import { MWCaption } from "@/backend/helpers/streams"; +import { MWCaption, MWCaptionType } from "@/backend/helpers/streams"; import { Icon, Icons } from "@/components/Icon"; import { FloatingCardView } from "@/components/popout/FloatingCard"; import { FloatingView } from "@/components/popout/FloatingView"; @@ -47,7 +47,10 @@ export function CaptionSelectionPopout(props: { const text = await result.text(); parseSubtitles(text); // This will throw if the file is invalid controls.setCaption(id, blobUrl); - controls.closePopout(); + // sometimes this doesn't work, so we add a small delay + setTimeout(() => { + controls.closePopout(); + }, 100); } ); @@ -107,6 +110,7 @@ export function CaptionSelectionPopout(props: { const customSubtitle = { langIso: "custom", url: URL.createObjectURL(e.target.files[0]), + type: MWCaptionType.UNKNOWN, }; setCaption(customSubtitle, false); }}