-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrealplay.js
60 lines (52 loc) · 1.28 KB
/
realplay.js
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
60
import React, { Component } from 'react';
import {
requireNativeComponent,
View,
UIManager,
findNodeHandle,
} from 'react-native';
const iface = {
name: 'RealPlayView',
propTypes: {
...View.propTypes // 包含默认的View的属性
},
};
const RCTYSRealPlayView = requireNativeComponent('RCTYSRealPlayView', iface);
const RCT_YS_REAL_PLAY_REF = 'RealPlayView';
export default class RealPlayView extends Component {
play(deviceSerial, cameraNO){
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs[RCT_YS_REAL_PLAY_REF]),
UIManager.RCTYSRealPlayView.Commands.play,
[deviceSerial, cameraNO]
);
}
stop(){
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs[RCT_YS_REAL_PLAY_REF]),
UIManager.RCTYSRealPlayView.Commands.stop,
null
);
}
_onPlay = (event) => {
if (this.props.onPlay) {
this.props.onPlay(event);
}
}
_onStop = (event) => {
if (this.props.onStop) {
this.props.onStop(event);
}
}
render() {
const { onPlay, onStop, ...props } = this.props;
return (
<RCTYSRealPlayView
{...props}
ref = {RCT_YS_REAL_PLAY_REF}
onPlay = {this._onPlay}
onStop = {this._onStop}
/>
);
}
}