在已连接但未运行onaddstream函数的iceConnectionState上说

时间:2018-12-24 00:38:17

标签: javascript react-native webrtc

我有类似的代码,该代码运行ice连接状态更改,并说this.pc.iceConnectionState已完成,但该功能 this.pc.onaddstream永远不会运行

我尝试重构代码并将其拆分为两个部分,但行为却相同

this.pc.oniceconnectionstatechange = () => {
  console.log('ICE STATE', this.pc.iceConnectionState);
  if (
    this.pc.iceConnectionState === 'failed' ||
    this.pc.iceConnectionState === 'disconnected' ||
    this.pc.iceConnectionState === 'closed'
  ) {
    console.log('Failed');
  } else if (this.pc.iceConnectionState === 'checking') {
    console.log('Checking');
  } else {
    this.setState({
      success: true,
    });
    console.log('Success');
  }
};

this.pc.onaddstream = e => {
  console.log('Stream event', e);
}

预期结果是在事件完成后记录流事件。

1 个答案:

答案 0 :(得分:0)

onAddStream已被淘汰。改用onTrack。