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 {Platform, TouchableOpacity, View, StatusBar} from 'react-native';
|
||||||
|
|
||||||
import Video, {
|
import Video, {
|
||||||
VideoRef,
|
|
||||||
SelectedVideoTrackType,
|
SelectedVideoTrackType,
|
||||||
BufferingStrategyType,
|
BufferingStrategyType,
|
||||||
SelectedTrackType,
|
SelectedTrackType,
|
||||||
ResizeMode,
|
ResizeMode,
|
||||||
|
type VideoRef,
|
||||||
type AudioTrack,
|
type AudioTrack,
|
||||||
type OnAudioTracksData,
|
type OnAudioTracksData,
|
||||||
type OnLoadData,
|
type OnLoadData,
|
||||||
@ -23,19 +23,17 @@ import Video, {
|
|||||||
type OnPlaybackStateChangedData,
|
type OnPlaybackStateChangedData,
|
||||||
type OnPlaybackRateChangeData,
|
type OnPlaybackRateChangeData,
|
||||||
type OnVideoTracksData,
|
type OnVideoTracksData,
|
||||||
type ReactVideoSource,
|
|
||||||
type VideoTrack,
|
type VideoTrack,
|
||||||
type SelectedTrack,
|
type SelectedTrack,
|
||||||
type SelectedVideoTrack,
|
type SelectedVideoTrack,
|
||||||
type EnumValues,
|
type EnumValues,
|
||||||
OnBandwidthUpdateData,
|
type OnBandwidthUpdateData,
|
||||||
ControlsStyles,
|
type ControlsStyles,
|
||||||
} from 'react-native-video';
|
} from 'react-native-video';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import {type AdditionalSourceInfo} from './types';
|
import {type AdditionalSourceInfo} from './types';
|
||||||
import {
|
import {
|
||||||
bufferConfig,
|
bufferConfig,
|
||||||
isAndroid,
|
|
||||||
srcList,
|
srcList,
|
||||||
textTracksSelectionBy,
|
textTracksSelectionBy,
|
||||||
audioTracksSelectionBy,
|
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 {Platform, TouchableOpacity, View, StatusBar} from 'react-native';
|
||||||
|
|
||||||
import Video, {
|
import Video, {
|
||||||
VideoRef,
|
|
||||||
SelectedVideoTrackType,
|
SelectedVideoTrackType,
|
||||||
BufferingStrategyType,
|
BufferingStrategyType,
|
||||||
SelectedTrackType,
|
SelectedTrackType,
|
||||||
ResizeMode,
|
ResizeMode,
|
||||||
|
type VideoRef,
|
||||||
type AudioTrack,
|
type AudioTrack,
|
||||||
type OnAudioTracksData,
|
type OnAudioTracksData,
|
||||||
type OnLoadData,
|
type OnLoadData,
|
||||||
@ -23,19 +23,17 @@ import Video, {
|
|||||||
type OnPlaybackStateChangedData,
|
type OnPlaybackStateChangedData,
|
||||||
type OnPlaybackRateChangeData,
|
type OnPlaybackRateChangeData,
|
||||||
type OnVideoTracksData,
|
type OnVideoTracksData,
|
||||||
type ReactVideoSource,
|
|
||||||
type VideoTrack,
|
type VideoTrack,
|
||||||
type SelectedTrack,
|
type SelectedTrack,
|
||||||
type SelectedVideoTrack,
|
type SelectedVideoTrack,
|
||||||
type EnumValues,
|
type EnumValues,
|
||||||
OnBandwidthUpdateData,
|
type OnBandwidthUpdateData,
|
||||||
ControlsStyles,
|
type ControlsStyles,
|
||||||
} from 'react-native-video';
|
} from 'react-native-video';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import {type AdditionalSourceInfo} from './types';
|
import {type AdditionalSourceInfo} from './types';
|
||||||
import {
|
import {
|
||||||
bufferConfig,
|
bufferConfig,
|
||||||
isAndroid,
|
|
||||||
srcList,
|
srcList,
|
||||||
textTracksSelectionBy,
|
textTracksSelectionBy,
|
||||||
audioTracksSelectionBy,
|
audioTracksSelectionBy,
|
||||||
|
@ -45,7 +45,7 @@ import {
|
|||||||
resolveAssetSourceForVideo,
|
resolveAssetSourceForVideo,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import NativeVideoManager from './specs/NativeVideoManager';
|
import NativeVideoManager from './specs/NativeVideoManager';
|
||||||
import {ViewType, type VideoSaveData, CmcdMode} from './types';
|
import {ViewType, CmcdMode, VideoRef} from './types';
|
||||||
import type {
|
import type {
|
||||||
OnLoadData,
|
OnLoadData,
|
||||||
OnTextTracksData,
|
OnTextTracksData,
|
||||||
@ -55,22 +55,6 @@ import type {
|
|||||||
ReactVideoSource,
|
ReactVideoSource,
|
||||||
} from './types';
|
} 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>(
|
const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
fullscreenOrientation,
|
fullscreenOrientation,
|
||||||
fullscreenAutorotate,
|
fullscreenAutorotate,
|
||||||
};
|
};
|
||||||
|
|
||||||
const setFullScreen = useCallback(
|
const setFullScreen = useCallback(
|
||||||
async (
|
async (
|
||||||
newVal: boolean,
|
newVal: boolean,
|
||||||
|
@ -14,7 +14,7 @@ export interface VideoRef {
|
|||||||
restoreUserInterfaceForPictureInPictureStopCompleted: (
|
restoreUserInterfaceForPictureInPictureStopCompleted: (
|
||||||
restore: boolean,
|
restore: boolean,
|
||||||
) => void;
|
) => void;
|
||||||
save: (options: object) => Promise<VideoSaveData>;
|
save: (options: object) => Promise<VideoSaveData> | void;
|
||||||
setVolume: (volume: number) => void;
|
setVolume: (volume: number) => void;
|
||||||
getCurrentPosition: () => Promise<number>;
|
getCurrentPosition: () => Promise<number>;
|
||||||
setFullScreen: (fullScreen: boolean) => void;
|
setFullScreen: (fullScreen: boolean) => void;
|
||||||
|
Loading…
Reference in New Issue
Block a user