Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
chore: ref react-native-video-controls types from github
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsgowtham committed Jun 24, 2023
1 parent 87398de commit 55be5e9
Showing 1 changed file with 66 additions and 22 deletions.
88 changes: 66 additions & 22 deletions src/types/react-native-video-controls.d.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,87 @@
// Ref: https://github.com/itsnubix/react-native-video-controls/blob/master/VideoPlayer.d.ts
// Note: react-native-video-controls with types def isn't released

declare module "react-native-video-controls" {
import * as React from "react";
import { VideoProperties } from "react-native-video";
import { Component } from "react";
import { StyleProp, ViewStyle } from "react-native";
import Video, { LoadError, VideoProperties } from "react-native-video";

interface DuckNavigator {
pop: () => void;
}

type VideoControlsProps = {
interface VideoPlayerProperties extends VideoProperties {
/** If true, clicking the fullscreen button will toggle the <Video /> component between cover/contain, set to false if you want to customize fullscreen behaviour */
toggleResizeModeOnFullscreen?: boolean;
/** The amountof time (in milliseconds) to animate the controls in and out. */
controlAnimationTiming?: number;
/** Tapping twice within this amount of time in milliseconds is considered a double tap. Single taps will not be actioned until this time has expired. */
doubleTapTime?: number;
/** Hide controls after X amount of time in milliseconds */
controlTimeout?: number;
/** If > 0, enable live scrubbing when moving the seek bar. The provided value is the minimum time step of the scrubbing in milliseconds. */
scrubbing?: number;
/** Show or hide the controls on first render */
showOnStart?: boolean;
/** React Native StyleSheet object that is appended to the <Video> component */
videoStyle?: ViewStyle;
/** When using the default React Native navigator and do not override the onBack function, you'll need to pass the navigator to the VideoPlayer for it to function */
navigator?: DuckNavigator;
/** Fill/handle colour of the seekbar */
seekColor?: string;
/** React Native StyleSheet object that is appended to the video's parent */
style?: StyleProp<ViewStyle>;
/** If true, single tapping anywhere on the video (other than a control) toggles between playing and paused. */
tapAnywhereToPause?: boolean;
/** Fired when the video enters fullscreen after the fullscreen button is pressed */
onEnterFullscreen?: () => void;
/** Fired when the video exits fullscreen after the fullscreen button is pressed */
onExitFullscreen?: () => void;
/** Fired when the controls disappear */
onHideControls?: () => void;
/** Fired when the controls appear */
onShowControls?: () => void;
onError?: () => void;
/** Fired when an error is encountered when loading the video */
onError?: (error: LoadError) => void;
/** Fired when the video is paused after the play/pause button is pressed */
onPause?: () => void;
/** Fired when the video begins playing after the play/pause button is pressed */
onPlay?: () => void;
/** Function fired when back button is pressed, override if using custom navigation */
onBack?: () => void;
/** Fired when the video is complete */
onEnd?: () => void;
toggleResizeModeOnFullscreen?: boolean;
controlTimeout?: number;
showOnStart?: boolean;
showTimeRemaining?: boolean;
tapAnywhereToPause?: boolean;
/** Hide the fullscreen button */
disableFullscreen?: boolean;
/** Hide the play/pause toggle */
disablePlayPause?: boolean;
/** Hide the seekbar */
disableSeekbar?: boolean;
/** Hide the Volume control */
disableVolume?: boolean;
/** Hide the timer */
disableTimer?: boolean;
/** Hide the back button */
disableBack?: boolean;
};
}

export default class Video extends React.Component<
VideoProperties & VideoControlsProps
> {
export default class VideoPlayer extends Component<VideoPlayerProperties> {
/**
* Seek to a time in the video.
*
* @param {number} time time to seek to in ms
*/
seekTo(time?: number): void;
/**
* Exposing player object for the ref.
*/
player: {
ref: {
presentFullscreenPlayer(): void;
dismissFullscreenPlayer(): void;
restoreUserInterfaceForPictureInPictureStopCompleted(
restored: boolean,
): void;
save(): Promise<void>;
seek(time: number, tolerance?: number): void;
};
/**
* The ref of underlying Video coomponent from
* 'react-native-video'.
* Can be used for various imperative tasks.
*/
ref: Video;
};
}
}

0 comments on commit 55be5e9

Please sign in to comment.