From 39cf477ceb37c6ecc38cbdd9077a556c81fd9c3d Mon Sep 17 00:00:00 2001 From: Seyed Mostafa Hasani Date: Fri, 12 Jul 2024 15:12:36 +0330 Subject: [PATCH] fix(example/basic): select resizeMode (#3989) * fix(example/basic): select resizeMode * chore: refactor the onResizeModeSelected function --- examples/basic/src/VideoPlayer.tsx | 5 ++++- examples/basic/src/components/Overlay.tsx | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/basic/src/VideoPlayer.tsx b/examples/basic/src/VideoPlayer.tsx index 031b6e12..05ec509c 100644 --- a/examples/basic/src/VideoPlayer.tsx +++ b/examples/basic/src/VideoPlayer.tsx @@ -30,6 +30,7 @@ import Video, { VideoTrack, SelectedTrack, SelectedVideoTrack, + EnumValues, } from 'react-native-video'; import styles from './styles'; import {AdditionalSourceInfo} from './types'; @@ -49,7 +50,9 @@ const VideoPlayer: FC = ({}) => { const [rate, setRate] = useState(1); const [volume, setVolume] = useState(1); const [muted, setMuted] = useState(false); - const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN); + const [resizeMode, setResizeMode] = useState>( + ResizeMode.CONTAIN, + ); const [duration, setDuration] = useState(0); const [currentTime, setCurrentTime] = useState(0); const [_, setVideoSize] = useState({videoWidth: 0, videoHeight: 0}); diff --git a/examples/basic/src/components/Overlay.tsx b/examples/basic/src/components/Overlay.tsx index b9c806e2..b4a196da 100644 --- a/examples/basic/src/components/Overlay.tsx +++ b/examples/basic/src/components/Overlay.tsx @@ -14,6 +14,7 @@ import MultiValueControl, { } from '../MultiValueControl.tsx'; import { AudioTrack, + EnumValues, ResizeMode, SelectedTrack, SelectedTrackType, @@ -55,8 +56,8 @@ type Props = { setRate: (value: number) => void; volume: number; setVolume: (value: number) => void; - resizeMode: ResizeMode; - setResizeMode: (value: ResizeMode) => void; + resizeMode: EnumValues; + setResizeMode: (value: EnumValues) => void; isLoading: boolean; srcListId: number; useCache: boolean; @@ -216,8 +217,8 @@ const _Overlay = forwardRef((props, ref) => { }; const onResizeModeSelected = (value: MultiValueControlPropType) => { - if (typeof value === 'object') { - setResizeMode(value); + if (typeof value === 'string') { + setResizeMode(value as EnumValues); } };