/
GroupCallVideoView.tsx
59 lines (50 loc) · 1.54 KB
/
GroupCallVideoView.tsx
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* eslint-disable @typescript-eslint/no-explicit-any */
import React, { createRef } from 'react';
import { ViewProps, findNodeHandle, requireNativeComponent } from 'react-native';
import { BaseVideoViewProps } from '../types';
import { LINKING_ERROR } from '../utils/constants';
import { Participant } from './Participant';
const MODULE_NAME = 'RNSBGroupCallVideoView';
const NativeViewModule = requireNativeComponent(MODULE_NAME);
if (!NativeViewModule) throw new Error(LINKING_ERROR);
export interface GroupCallVideoViewProps extends BaseVideoViewProps, ViewProps {
participant?: Participant;
roomId?: string;
}
export default class GroupCallVideoView extends React.PureComponent<GroupCallVideoViewProps> {
private ref = createRef<any>();
private get handle() {
const nodeHandle = findNodeHandle(this.ref.current as any);
if (nodeHandle == null || nodeHandle === -1) {
throw new Error('Cannot found VideoView');
}
return nodeHandle;
}
private get validProps() {
const {
android_zOrderMediaOverlay = false,
mirror = false,
resizeMode = 'contain',
participant,
roomId,
style,
...rest
} = this.props;
return {
zOrderMediaOverlay: android_zOrderMediaOverlay,
mirror,
resizeMode,
participantId: participant?.participantId,
roomId,
state: participant?.state,
style,
...rest,
};
}
public get videoViewId() {
return this.handle;
}
render() {
return <NativeViewModule ref={this.ref as any} {...this.validProps} />;
}
}