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,
|
VideoTrack,
|
||||||
SelectedTrack,
|
SelectedTrack,
|
||||||
SelectedVideoTrack,
|
SelectedVideoTrack,
|
||||||
|
EnumValues,
|
||||||
} from 'react-native-video';
|
} from 'react-native-video';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import {AdditionalSourceInfo} from './types';
|
import {AdditionalSourceInfo} from './types';
|
||||||
@ -49,7 +50,9 @@ const VideoPlayer: FC<Props> = ({}) => {
|
|||||||
const [rate, setRate] = useState(1);
|
const [rate, setRate] = useState(1);
|
||||||
const [volume, setVolume] = useState(1);
|
const [volume, setVolume] = useState(1);
|
||||||
const [muted, setMuted] = useState(false);
|
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 [duration, setDuration] = useState(0);
|
||||||
const [currentTime, setCurrentTime] = useState(0);
|
const [currentTime, setCurrentTime] = useState(0);
|
||||||
const [_, setVideoSize] = useState({videoWidth: 0, videoHeight: 0});
|
const [_, setVideoSize] = useState({videoWidth: 0, videoHeight: 0});
|
||||||
|
@ -14,6 +14,7 @@ import MultiValueControl, {
|
|||||||
} from '../MultiValueControl.tsx';
|
} from '../MultiValueControl.tsx';
|
||||||
import {
|
import {
|
||||||
AudioTrack,
|
AudioTrack,
|
||||||
|
EnumValues,
|
||||||
ResizeMode,
|
ResizeMode,
|
||||||
SelectedTrack,
|
SelectedTrack,
|
||||||
SelectedTrackType,
|
SelectedTrackType,
|
||||||
@ -55,8 +56,8 @@ type Props = {
|
|||||||
setRate: (value: number) => void;
|
setRate: (value: number) => void;
|
||||||
volume: number;
|
volume: number;
|
||||||
setVolume: (value: number) => void;
|
setVolume: (value: number) => void;
|
||||||
resizeMode: ResizeMode;
|
resizeMode: EnumValues<ResizeMode>;
|
||||||
setResizeMode: (value: ResizeMode) => void;
|
setResizeMode: (value: EnumValues<ResizeMode>) => void;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
srcListId: number;
|
srcListId: number;
|
||||||
useCache: boolean;
|
useCache: boolean;
|
||||||
@ -216,8 +217,8 @@ const _Overlay = forwardRef<VideoRef, Props>((props, ref) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onResizeModeSelected = (value: MultiValueControlPropType) => {
|
const onResizeModeSelected = (value: MultiValueControlPropType) => {
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'string') {
|
||||||
setResizeMode(value);
|
setResizeMode(value as EnumValues<ResizeMode>);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user