mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-25 07:11:50 +01:00
add support for captions
This commit is contained in:
parent
8240fae8fa
commit
eb306f3772
@ -1,11 +1,12 @@
|
|||||||
import { IconPatch } from "components/buttons/IconPatch";
|
import { IconPatch } from "components/buttons/IconPatch";
|
||||||
import { Icons } from "components/Icon";
|
import { Icons } from "components/Icon";
|
||||||
import { Loading } from "components/layout/Loading";
|
import { Loading } from "components/layout/Loading";
|
||||||
import { MWMediaStream } from "providers";
|
import { MWMediaCaption, MWMediaStream } from "providers";
|
||||||
import { ReactElement, useEffect, useRef, useState } from "react";
|
import { ReactElement, useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
export interface VideoPlayerProps {
|
export interface VideoPlayerProps {
|
||||||
source: MWMediaStream;
|
source: MWMediaStream;
|
||||||
|
captions: MWMediaCaption[];
|
||||||
startAt?: number;
|
startAt?: number;
|
||||||
onProgress?: (event: ProgressEvent) => void;
|
onProgress?: (event: ProgressEvent) => void;
|
||||||
}
|
}
|
||||||
@ -74,6 +75,9 @@ export function VideoPlayer(props: VideoPlayerProps) {
|
|||||||
{!mustUseHls ? (
|
{!mustUseHls ? (
|
||||||
<source src={props.source.url} type="video/mp4" />
|
<source src={props.source.url} type="video/mp4" />
|
||||||
) : null}
|
) : null}
|
||||||
|
{props.captions.map((v) => (
|
||||||
|
<track key={v.id} kind="captions" label={v.label} src={v.url} />
|
||||||
|
))}
|
||||||
</video>
|
</video>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -69,7 +69,8 @@ export const theFlixScraper: MWMediaProvider = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = JSON.parse(prop.textContent);
|
const data = JSON.parse(prop.textContent);
|
||||||
return { url: data.props.pageProps.videoUrl, type: "mp4" };
|
|
||||||
|
return { url: data.props.pageProps.videoUrl, type: "mp4", captions: [] };
|
||||||
},
|
},
|
||||||
|
|
||||||
async getSeasonDataFromMedia(
|
async getSeasonDataFromMedia(
|
||||||
|
@ -13,9 +13,15 @@ export interface MWPortableMedia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type MWMediaStreamType = "m3u8" | "mp4";
|
export type MWMediaStreamType = "m3u8" | "mp4";
|
||||||
|
export interface MWMediaCaption {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
export interface MWMediaStream {
|
export interface MWMediaStream {
|
||||||
url: string;
|
url: string;
|
||||||
type: MWMediaStreamType;
|
type: MWMediaStreamType;
|
||||||
|
captions: MWMediaCaption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MWMediaMeta extends MWPortableMedia {
|
export interface MWMediaMeta extends MWPortableMedia {
|
||||||
|
@ -52,6 +52,7 @@ function StyledMediaView(props: StyledMediaViewProps) {
|
|||||||
return (
|
return (
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
source={props.stream}
|
source={props.stream}
|
||||||
|
captions={props.stream.captions}
|
||||||
onProgress={(e) => updateProgress(e)}
|
onProgress={(e) => updateProgress(e)}
|
||||||
startAt={startAtTime}
|
startAt={startAtTime}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user