У меня есть реализация opentok-реакции, для которой я бы хотел обновить разрешение издателя.К сожалению, кажется, что OTPublisher будет обновляться только при изменении определенных значений, и разрешение не является одним из них.В документации я вижу, что getPublisher () следует использовать для обновления издателя после его инициализации, но я не вижу примеров того, как это делается.Вот компонент, который мне нужно обновить:
import React, { Component } from 'react';
import { OTSession, OTPublisher } from 'opentok-react';
const styles = {
publisherWindow: {
height: '155px',
width: '230px',
style: { buttonDisplayMode: 'off' },
},
};
type Props = {
sessionId: string,
sessionToken: string,
apiKey: string,
muted: boolean,
style?: Object,
onError: Function,
eventHandlers: Object,
lowerResolution: boolean,
};
type State = {
publish: boolean,
};
class TokboxPublisher extends Component<Props, State> {
state = {
publish: true,
};
static SURVEYOR_STREAM_NAME = 'Surveyor Stream';
componentWillMount() {
this.retryTimeout = setTimeout(this.retry, 6000);
};
componentWillUnmount() {
if (this.retryTimeout) {
clearTimeout(this.retryTimeout);
}
};
onPublish = () => {
console.log('Publishing...');
if (this.retryTimeout) {
clearTimeout(this.retryTimeout);
}
};
retry = () => {
this.retryTimeout = undefined;
console.log('Retrying publish...');
this.setState({ publish: false }, () => this.setState({ publish: true }));
};
render() {
if (!this.state.publish) {
return null;
}
console.log('lowerResolution: ', this.props.lowerResolution);
return (
<OTSession
apiKey={this.props.apiKey}
sessionId={this.props.sessionId}
token={this.props.sessionToken}
eventHandlers={this.props.eventHandlers}
>
<OTPublisher
ref={this.otPublisher}
properties={{
publishAudio: !this.props.muted,
resolution: this.props.lowerResolution ? '320x240' : '640x480',
frameRate: this.props.lowerResolution ? 1 : 30,
name: TokboxPublisher.SURVEYOR_STREAM_NAME,
...styles.publisherWindow,
...this.props.style,
}}
onPublish={this.onPublish}
onError={this.props.onError}
/>
</OTSession>
);
}
}
export default TokboxPublisher;
Как бы я использовал getPublisher () в этом коде, чтобы получить разрешение для обновления, когда свойство lowerResolution изменится на 'true'?