chore: cleanup ref (#4288)
* refactor: cleanup ref * fix: video-ref type * refactor: cleanup code
This commit is contained in:
parent
681aed0aed
commit
de81829d73
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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>(
|
||||
(
|
||||
{
|
||||
|
@ -123,6 +123,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||
fullscreenOrientation,
|
||||
fullscreenAutorotate,
|
||||
};
|
||||
|
||||
const setFullScreen = useCallback(
|
||||
async (
|
||||
newVal: boolean,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user