我正在尝试实现反应生态的opentok lib,但我面临着一些我无法弄清楚的问题。第一个,我认为最重要的是,我无法在不崩溃的情况下以订阅者的身份连接到会话,这仅在Android设备上发生,为此,我看不出它是否在工作两个之间的连接手机。
我在做什么错?
预约
import React, { Component } from 'react';
import { OTSession } from 'opentok-react-native';
import { TokBox } from '../../../helpers/constants';
import PublisherStream from './PublisherStream';
import SubscriberStream from './SubscriberStream';
class Appointment extends Component {
static navigationOptions = {
header: null
};
render() {
const { navigation: { navigate, state: { params } } } = this.props;
return (
<OTSession style={{ flex: 1 }}
apiKey={TokBox.API_KEY}
sessionId={params.sessionId}
token={params.token}
eventHandlers={this.sessionEventHandlers}>
<PublisherStream style={{ borderColor: 'red', borderWidth: 3, height: '50%' }} />
<SubscriberStream style={{ borderColor: 'blue', borderWidth: 3, height: '50%' }} />
</OTSession>
);
}
}
export default Appointment;
PublisherStream
import React, { Component } from 'react';
import { OTPublisher } from 'opentok-react-native';
class PublisherStream extends Component {
publisherEventHandlers = {
streamCreated: (event) => {
console.log('Publisher stream created!', event);
},
streamDestroyed: (event) => {
console.log('Publisher stream destroyed!', event);
}
};
render() {
return (
<OTPublisher style={this.props.style} eventHandlers={this.publisherEventHandlers} />
);
}
}
export default PublisherStream;
sisscriberstream
import React, { Component } from 'react';
import { OTSubscriber } from 'opentok-react-native';
class SubscriberStream extends Component {
subscriberProperties = {
subscribeToAudio: true,
subscribeToVideo: true,
};
subscriberEventHandler = {
connected(event) {
console.log('connected', event);
},
disconnected(event) {
console.log('disconnected', event);
},
videoDataReceived(event) {
console.log('videoDataReceived', event);
},
videoEnabled(event) {
console.log('videoEnabled', event);
},
videoNetworkStats(event) {
console.log('videoNetworkStats', event);
}
};
render() {
return (
<OTSubscriber
properties={this.subscriberProperties}
eventHandlers={this.subscriberEventHandler}
style={this.props.style}
/>
);
}
}
export default SubscriberStream;
package.json
{
{...omitted}
"dependencies": {
"opentok-react-native": "^0.9.5",
"react": "^16.8.1",
"react-native": "0.58.4",
},
{...omitted}
}
实际上,问题是我试图从订户流式传输视频,这不能以这种方式进行....
答案在这里:https://github.com/opentok/opentok-react-native/issues/239