-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerView.js
More file actions
29 lines (21 loc) · 1.03 KB
/
PlayerView.js
File metadata and controls
29 lines (21 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React, {useCallback} from 'react';
import {requireNativeComponent, ViewPropTypes,} from 'react-native';
const RCTPlayerView = requireNativeComponent('RIVSPlayer');
const PlayerView = (props) => {
const { onChangeState, onChangeVideoSize, onFailWithError,onOutputCue, ...viewProps } = props;
const handleChangeState = useCallback(({ nativeEvent }) => {
onChangeState?.(nativeEvent?.code, nativeEvent?.msg);
}, []);
const handleChangeVideoSize = useCallback(({ nativeEvent }) => {
onChangeVideoSize?.(nativeEvent?.width, nativeEvent?.height);
}, []);
const handleFailWithError = useCallback(({ nativeEvent }) => {
onFailWithError?.(nativeEvent?.code);
}, []);
const handleOutputCue = useCallback(({ nativeEvent }) => {
onOutputCue?.(nativeEvent);
}, []);
return <RCTPlayerView {...props} onChangeState={handleChangeState} onChangeVideoSize={handleChangeVideoSize} onFailWithError={handleFailWithError} onOutputCue={handleOutputCue} />;
};
PlayerView.propTypes = ViewPropTypes;
export default PlayerView;