chore: cleanup ref (#4288)

* refactor: cleanup ref
* fix: video-ref type
* refactor: cleanup code
This commit is contained in:
Kamil Moskała 2024-11-15 21:17:56 +01:00 committed by GitHub
parent 681aed0aed
commit de81829d73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 30 deletions

View File

@ -1,13 +1,13 @@
import React, {type FC, useCallback, useRef, useState, useEffect} from 'react';
import React, {useCallback, useRef, useState, useEffect} from 'react';
import {Platform, TouchableOpacity, View, StatusBar} from 'react-native';
import Video, {
VideoRef,
SelectedVideoTrackType,
BufferingStrategyType,
SelectedTrackType,
ResizeMode,
type VideoRef,
type AudioTrack,
type OnAudioTracksData,
type OnLoadData,
@ -23,19 +23,17 @@ import Video, {
type OnPlaybackStateChangedData,
type OnPlaybackRateChangeData,
type OnVideoTracksData,
type ReactVideoSource,
type VideoTrack,
type SelectedTrack,
type SelectedVideoTrack,
type EnumValues,
OnBandwidthUpdateData,
ControlsStyles,
type OnBandwidthUpdateData,
type ControlsStyles,
} from 'react-native-video';
import styles from './styles';
import {type AdditionalSourceInfo} from './types';
import {
bufferConfig,
isAndroid,
srcList,
textTracksSelectionBy,
audioTracksSelectionBy,

View File

@ -1,13 +1,13 @@
import React, {type FC, useCallback, useRef, useState, useEffect} from 'react';
import React, {useCallback, useRef, useState, useEffect} from 'react';
import {Platform, TouchableOpacity, View, StatusBar} from 'react-native';
import Video, {
VideoRef,
SelectedVideoTrackType,
BufferingStrategyType,
SelectedTrackType,
ResizeMode,
type VideoRef,
type AudioTrack,
type OnAudioTracksData,
type OnLoadData,
@ -23,19 +23,17 @@ import Video, {
type OnPlaybackStateChangedData,
type OnPlaybackRateChangeData,
type OnVideoTracksData,
type ReactVideoSource,
type VideoTrack,
type SelectedTrack,
type SelectedVideoTrack,
type EnumValues,
OnBandwidthUpdateData,
ControlsStyles,
type OnBandwidthUpdateData,
type ControlsStyles,
} from 'react-native-video';
import styles from './styles';
import {type AdditionalSourceInfo} from './types';
import {
bufferConfig,
isAndroid,
srcList,
textTracksSelectionBy,
audioTracksSelectionBy,

View File

@ -45,7 +45,7 @@ import {
resolveAssetSourceForVideo,
} from './utils';
import NativeVideoManager from './specs/NativeVideoManager';
import {ViewType, type VideoSaveData, CmcdMode} from './types';
import {ViewType, CmcdMode, VideoRef} from './types';
import type {
OnLoadData,
OnTextTracksData,
@ -55,22 +55,6 @@ import type {
ReactVideoSource,
} from './types';
export interface VideoRef {
seek: (time: number, tolerance?: number) => void;
resume: () => void;
pause: () => void;
presentFullscreenPlayer: () => void;
dismissFullscreenPlayer: () => void;
restoreUserInterfaceForPictureInPictureStopCompleted: (
restore: boolean,
) => void;
setVolume: (volume: number) => void;
setFullScreen: (fullScreen: boolean) => void;
setSource: (source?: ReactVideoSource) => void;
save: (options: object) => Promise<VideoSaveData> | void;
getCurrentPosition: () => Promise<number>;
}
const Video = forwardRef<VideoRef, ReactVideoProps>(
(
{

View File

@ -123,6 +123,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
fullscreenOrientation,
fullscreenAutorotate,
};
const setFullScreen = useCallback(
async (
newVal: boolean,

View File

@ -14,7 +14,7 @@ export interface VideoRef {
restoreUserInterfaceForPictureInPictureStopCompleted: (
restore: boolean,
) => void;
save: (options: object) => Promise<VideoSaveData>;
save: (options: object) => Promise<VideoSaveData> | void;
setVolume: (volume: number) => void;
getCurrentPosition: () => Promise<number>;
setFullScreen: (fullScreen: boolean) => void;