RTCIceTransport
接口的
onselectedcandidatepairchange
event handler specifies a function to be called to handle the
selectedcandidatepairchange
event, which is fired when the ICE agent selects a new candidate pair to be used for the connection.
RTCIceTransport.onselectedcandidatepairchange = candidatePairHandler;
This propoerty should be set to reference an event handler function to be called by the ICE agent when it discovers a new candidate pair that the
RTCIceTransport
will be using for communication with the remote peer. This event will occur at least once, and may occur more than once if the ICE agent continues to identify candidate pairs that will work better, more closely match the requested parameters, and so forth.
The event handler can determine the current state by calling the transport's
getSelectedCandidatePair()
method, which returns a
RTCIceCandidatePair
whose
RTCIceCandidatePair.local
and
RTCIceCandidatePair.global
properties specify
RTCIceCandidate
objects describing the local and remote candidates that are currently being used.
In this example, an event handler for
selectedcandidatepairchange
is set up to update an on-screen display showing the protocol used by the currently selected candidate pair.
var iceTransport = pc.getSenders()[0].transport.iceTransport;
var localProto = document.getElementById("local-protocol");
var remoteProto = document.getElementById("remote-protocol");
iceTransport.onselectedcandidatepairchange = function(event) {
var pair = iceTransport.getSelectedCandidatePair();
localProtocol.innerText = pair.local.protocol.toUpperCase();
remoteProtocol.innerText = pair.remote.protocol.toUpperCase();
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCIceTransport.onselectedcandidatepairchange' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onselectedcandidatepairchange
|
Chrome No | Edge No | Firefox No | IE No | Opera No | Safari No | WebView Android No | Chrome Android No | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android No |
不支持
selectedcandidatepair
event and its type,
事件
.
RTCIceTransport
:
onstatechange
and
ongatheringstatechange
RTCIceTransport
component
gatheringState
getRemoteCandidates()
ongatheringstatechange
onselectedcandidatepairchange
onstatechange
role
state
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCPeerConnection
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent