Skip to content

Commit

Permalink
fix: fix save pause and resume types
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier committed Oct 25, 2023
1 parent e1a2d6d commit b7a1751
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-video",
"version": "6.0.0-alpha.10",
"version": "6.0.0-alpha.8",
"description": "A <Video /> element for react-native",
"main": "lib/index",
"source": "src/index",
Expand Down
17 changes: 11 additions & 6 deletions src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import type {
OnVideoTracksData,
} from './types/events';

export type VideoSaveData = {
uri: string;
};

export interface VideoRef {
seek: (time: number, tolerance?: number) => void;
resume: () => void;
Expand All @@ -46,6 +50,7 @@ export interface VideoRef {
restoreUserInterfaceForPictureInPictureStopCompleted: (
restore: boolean,
) => void;
save: () => Promise<VideoSaveData>;
}

const Video = forwardRef<VideoRef, ReactVideoProps>(
Expand Down Expand Up @@ -235,16 +240,16 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
setIsFullscreen(false);
}, [setIsFullscreen]);

const save = useCallback(async () => {
await VideoManager.save(getReactTag(nativeRef));
const save = useCallback(() => {
return VideoManager.save(getReactTag(nativeRef));
}, []);

const pause = useCallback(async () => {
await VideoManager.setPlayerPauseState(true, getReactTag(nativeRef));
const pause = useCallback(() => {
return VideoManager.setPlayerPauseState(true, getReactTag(nativeRef));
}, []);

const resume = useCallback(async () => {
await VideoManager.setPlayerPauseState(false, getReactTag(nativeRef));
const resume = useCallback(() => {
return VideoManager.setPlayerPauseState(false, getReactTag(nativeRef));
}, []);

const restoreUserInterfaceForPictureInPictureStopCompleted = useCallback(
Expand Down
6 changes: 5 additions & 1 deletion src/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,12 @@ export interface VideoNativeProps extends ViewProps {

export type VideoComponentType = HostComponent<VideoNativeProps>;

export type VideoSaveData = {
uri: string;
};

export interface VideoManagerType {
save: (reactTag: number) => Promise<void>;
save: (reactTag: number) => Promise<VideoSaveData>;
setPlayerPauseState: (paused: boolean, reactTag: number) => Promise<void>;
setLicenseResult: (
result: string,
Expand Down

0 comments on commit b7a1751

Please sign in to comment.