From de81829d73ebb7450fc74ba23af2b77fb7315f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Moska=C5=82a?= <91079590+moskalakamil@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:17:56 +0100 Subject: [PATCH] chore: cleanup ref (#4288) * refactor: cleanup ref * fix: video-ref type * refactor: cleanup code --- examples/bare/src/BasicExample.tsx | 10 ++++------ examples/expo/src/BasicExample.tsx | 10 ++++------ src/Video.tsx | 18 +----------------- src/Video.web.tsx | 1 + src/types/video-ref.ts | 2 +- 5 files changed, 11 insertions(+), 30 deletions(-) diff --git a/examples/bare/src/BasicExample.tsx b/examples/bare/src/BasicExample.tsx index 98e189ded1..2997cd58b2 100644 --- a/examples/bare/src/BasicExample.tsx +++ b/examples/bare/src/BasicExample.tsx @@ -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, diff --git a/examples/expo/src/BasicExample.tsx b/examples/expo/src/BasicExample.tsx index 98e189ded1..2997cd58b2 100644 --- a/examples/expo/src/BasicExample.tsx +++ b/examples/expo/src/BasicExample.tsx @@ -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, diff --git a/src/Video.tsx b/src/Video.tsx index 7d9b68269e..50cc352498 100644 --- a/src/Video.tsx +++ b/src/Video.tsx @@ -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 | void; - getCurrentPosition: () => Promise; -} - const Video = forwardRef( ( { diff --git a/src/Video.web.tsx b/src/Video.web.tsx index ee06a516dd..a8b5a218a3 100644 --- a/src/Video.web.tsx +++ b/src/Video.web.tsx @@ -123,6 +123,7 @@ const Video = forwardRef( fullscreenOrientation, fullscreenAutorotate, }; + const setFullScreen = useCallback( async ( newVal: boolean, diff --git a/src/types/video-ref.ts b/src/types/video-ref.ts index 04b1fc0a56..69bbe42205 100644 --- a/src/types/video-ref.ts +++ b/src/types/video-ref.ts @@ -14,7 +14,7 @@ export interface VideoRef { restoreUserInterfaceForPictureInPictureStopCompleted: ( restore: boolean, ) => void; - save: (options: object) => Promise; + save: (options: object) => Promise | void; setVolume: (volume: number) => void; getCurrentPosition: () => Promise; setFullScreen: (fullScreen: boolean) => void;