RTCPeerConnection.onaddstream
当类型为 MediaStreamEvent 的 addstream 事件发生时,通过RTCPeerConnection 触发 RTCPeerConnection.onaddstream 事件处理函数。当远程媒体流MediaStream 添加到连接后发送事件。当RTCPeerConnection.setRemoteDescription() 后此事件立即被调用而不需要等待 SDP 交换完成。
此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
当类型为 MediaStreamEvent 的 addstream 事件发生时,通过RTCPeerConnection 触发 RTCPeerConnection.onaddstream 事件处理函数。当远程媒体流MediaStream 添加到连接后发送事件。当RTCPeerConnection.setRemoteDescription() 后此事件立即被调用而不需要等待 SDP 交换完成。
peerconnection.onaddstream = function;
function 是用户自定义的一个函数,写法上不带 () 和任何参数,也可以是一个匿名函数,例如 function(event) {...}。事件处理函数通常有个 event 做参数,类型为 MediaStreamEvent.pc.onaddstream = function (ev) {
alert("onaddstream event detected!");
};