Skip to content

Commit

Permalink
fix(example/basic): select resizeMode (#3989)
Browse files Browse the repository at this point in the history
* fix(example/basic): select resizeMode

* chore: refactor the onResizeModeSelected function
  • Loading branch information
seyedmostafahasani authored Jul 12, 2024
1 parent 21e78ea commit 39cf477
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Video, {
VideoTrack,
SelectedTrack,
SelectedVideoTrack,
EnumValues,
} from 'react-native-video';
import styles from './styles';
import {AdditionalSourceInfo} from './types';
Expand All @@ -49,7 +50,9 @@ const VideoPlayer: FC<Props> = ({}) => {
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<EnumValues<ResizeMode>>(
ResizeMode.CONTAIN,
);
const [duration, setDuration] = useState(0);
const [currentTime, setCurrentTime] = useState(0);
const [_, setVideoSize] = useState({videoWidth: 0, videoHeight: 0});
Expand Down
9 changes: 5 additions & 4 deletions examples/basic/src/components/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MultiValueControl, {
} from '../MultiValueControl.tsx';
import {
AudioTrack,
EnumValues,
ResizeMode,
SelectedTrack,
SelectedTrackType,
Expand Down Expand Up @@ -55,8 +56,8 @@ type Props = {
setRate: (value: number) => void;
volume: number;
setVolume: (value: number) => void;
resizeMode: ResizeMode;
setResizeMode: (value: ResizeMode) => void;
resizeMode: EnumValues<ResizeMode>;
setResizeMode: (value: EnumValues<ResizeMode>) => void;
isLoading: boolean;
srcListId: number;
useCache: boolean;
Expand Down Expand Up @@ -216,8 +217,8 @@ const _Overlay = forwardRef<VideoRef, Props>((props, ref) => {
};

const onResizeModeSelected = (value: MultiValueControlPropType) => {
if (typeof value === 'object') {
setResizeMode(value);
if (typeof value === 'string') {
setResizeMode(value as EnumValues<ResizeMode>);
}
};

Expand Down

0 comments on commit 39cf477

Please sign in to comment.