From e5b1f998072fc61ade8dd897efb79234a15fd50a Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 14 Nov 2024 10:30:43 +0100 Subject: [PATCH 1/3] refactor: cleanup ref --- src/Video.tsx | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) 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( ( { From 7ae6b67608a9213753f58b06e85699511a4b9a76 Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 14 Nov 2024 10:31:10 +0100 Subject: [PATCH 2/3] fix: video-ref type --- src/types/video-ref.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From c2b2b3f5726dad8de7f2b48af247b8a3d62b29bc Mon Sep 17 00:00:00 2001 From: Kamil Date: Thu, 14 Nov 2024 10:31:35 +0100 Subject: [PATCH 3/3] refactor: cleanup code --- examples/bare/src/BasicExample.tsx | 10 ++++------ examples/expo/src/BasicExample.tsx | 10 ++++------ src/Video.web.tsx | 1 + 3 files changed, 9 insertions(+), 12 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.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,