【发布时间】:2021-05-11 17:50:36
【问题描述】:
我尝试做一个简单的 WebRTC p2p 视频聊天浏览器应用程序。我设置了一个信号服务器并让两个对等方进行所有SDP 和ICE 握手。我的一些代码sn-p:
pc = new RTCPeerConnection(config);
pc.onicecandidate = (event) => {
...
}
pc.ontrack(event) =>{
if (event.track.kind === 'video') {
// add the stream as the srcObject of a video tag
}
event.streams[0].onremovetrack = (e) => {
// want to remove the stream from the video tag
}
}
当对等节点完成后,我会执行以下操作:
pc.stop();
我只是关闭了 RTCPeerConnection。但我没有看到 onremovetrack 在其他对等方上被触发。
关闭对等点以便通知另一个对等点并触发onremovetrack 的正确方法是什么?
【问题讨论】:
标签: webrtc rtcpeerconnection mediastreamtrack