wip: subtitles and onVideoLoad stuff

This commit is contained in:
Fredrik Burmester
2024-10-14 11:14:34 +02:00
parent 092f5e73d7
commit 67be97d857
8 changed files with 144 additions and 58 deletions

View File

@@ -67,6 +67,7 @@ export type VlcPlayerViewProps = {
onVideoProgress?: (event: ProgressUpdatePayload) => void;
onVideoStateChange?: (event: PlaybackStatePayload) => void;
onVideoLoadStart?: (event: VideoLoadStartPayload) => void;
onVideoLoadEnd?: (event: VideoLoadStartPayload) => void;
};
export interface VlcPlayerViewRef {
@@ -87,4 +88,5 @@ export interface VlcPlayerViewRef {
getChapters: () => Promise<ChapterInfo[] | null>;
setVideoCropGeometry: (geometry: string | null) => Promise<void>;
getVideoCropGeometry: () => Promise<string | null>;
setSubtitleURL: (url: string) => Promise<void>;
}

View File

@@ -5,8 +5,6 @@ import {
VlcPlayerViewProps,
VlcPlayerViewRef,
VlcPlayerSource,
TrackInfo,
ChapterInfo,
} from "./VlcPlayer.types";
interface NativeViewRef extends VlcPlayerViewRef {
@@ -80,6 +78,9 @@ const VlcPlayerView = React.forwardRef<VlcPlayerViewRef, VlcPlayerViewProps>(
const geometry = await nativeRef.current?.getVideoCropGeometry();
return geometry ?? null;
},
setSubtitleURL: async (url: string) => {
await nativeRef.current?.setSubtitleURL(url);
},
}));
const {
@@ -93,6 +94,7 @@ const VlcPlayerView = React.forwardRef<VlcPlayerViewRef, VlcPlayerViewProps>(
onVideoLoadStart,
onVideoStateChange,
onVideoProgress,
onVideoLoadEnd,
...otherProps
} = props;
@@ -111,6 +113,7 @@ const VlcPlayerView = React.forwardRef<VlcPlayerViewRef, VlcPlayerViewProps>(
volume={volume}
videoAspectRatio={videoAspectRatio}
onVideoLoadStart={onVideoLoadStart}
onVideoLoadEnd={onVideoLoadEnd}
onVideoStateChange={onVideoStateChange}
onVideoProgress={onVideoProgress}
/>