React Native:在视频流顶部显示OpenTok Publisher的名称

时间:2019-01-25 05:43:36

标签: react-native opentok tokbox

我正在尝试使用OpenTok React Native软件包获取发布者的名称以显示在视频流的顶部(在发布者和订户的两端)。

根据OTPublisher component的文档,只需将name键作为属性之一传递即可。

我尝试过在属性中添加名称,并将其传递给OTPublisher组件,但是它不会显示在Publisher或Subscriber上。我还需要做其他事情吗?

这是我正在使用的示例代码:

class App extends Component {
  constructor(props) {
    super(props);

    this.publisherProperties = {
      publishAudio: false,
      cameraPosition: 'front',
      name: 'Test Name'
    };

    this.publisherEventHandlers = {
      streamCreated: event => {
        console.log('Publisher stream created!', event);
      },
      streamDestroyed: event => {
        console.log('Publisher stream destroyed!', event);
      }
    };
  }

  render() {
    return (
      <OTSession apiKey="your-api-key" sessionId="your-session-id" token="your-session-token">
        <OTPublisher
          properties={this.publisherProperties}
          eventHandlers={this.publisherEventHandlers}
          style={{ height: 100, width: 100 }}
        />
      </OTSession>
    );
  }
}

1 个答案:

答案 0 :(得分:0)

此处是TokBox开发人员的传播者。

OpenTok React Native库呈现由OpenTok iOS和Android SDK提供支持的本机视图。这些移动SDK不支持叠加了name的视频的呈现,目前仅可通过OpenTok JS SDK使用。

如果您在网络上订阅了相同的会话(可以使用OpenTok Playground tool进行测试),则会看到设置name属性起作用。