我有类似的代码,该代码运行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);
}
预期结果是在事件完成后记录流事件。
答案 0 :(得分:0)
onAddStream已被淘汰。改用onTrack。