fix(example/basic): select resizeMode (#3989)
* fix(example/basic): select resizeMode * chore: refactor the onResizeModeSelected function
This commit is contained in:
parent
21e78ea2c1
commit
39cf477ceb
@ -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<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});
|
||||
|
@ -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<ResizeMode>;
|
||||
setResizeMode: (value: EnumValues<ResizeMode>) => void;
|
||||
isLoading: boolean;
|
||||
srcListId: number;
|
||||
useCache: boolean;
|
||||
@ -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>);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user