-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathyasea.js
84 lines (68 loc) · 1.78 KB
/
yasea.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
import React, {Component, PropTypes} from 'react';
import {
NativeAppEventEmitter,
NativeModules,
Platform,
StyleSheet,
requireNativeComponent,
DeviceEventEmitter,
View
} from 'react-native';
var RNYaseaModule = NativeModules.RNYaseaModule;
class YaseaView extends Component {
constructor(props) {
super(props);
this.listeners = [];
}
componentWillMount() {
let that = this;
this.listeners.push(NativeAppEventEmitter.addListener('publish',
(message) => {
that.props.onPublish(message);
}
));
this.listeners.push(NativeAppEventEmitter.addListener('record',
(message) => {
that.props.onRecord(message);
}
));
this.listeners.push(NativeAppEventEmitter.addListener('network',
(message) => {
that.props.onNetwork(message);
}
));
}
componentWillUnmount() {
this.listeners.forEach(sub => sub.remove());
}
render() {
return <NativeRNYaseaView {...this.props}/>;
}
startPublish(streamUrl, streamkey) {
let url = streamUrl + '/' + streamkey;
RNYaseaModule.startPublish(url);
}
stopPublish() {
RNYaseaModule.stopPublish();
}
setOutputResolution(width, height) {
RNYaseaModule.setOutputResolution(width, height);
}
}
YaseaView.defaultProps = {
onPublish: () => {
},
onRecord: () => {
},
onNetwork: () => {
}
};
YaseaView.propTypes = {
...View.propTypes,
onPublish: PropTypes.func,
onRecord: PropTypes.func,
onNetwork: PropTypes.func
};
var NativeRNYaseaView = requireNativeComponent('RNYaseaView', YaseaView);
module.exports = YaseaView;