这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
RTCPeerConnection.onicegatheringstatechange
property is an
EventHandler
which specifies a function to be called when the
icegatheringstatechange
event is sent to an
RTCPeerConnection
instance. This happens when the ICE gathering state—that is, whether or not the ICE agent is actively gathering candidates—changes.
You don't need to watch for this event unless you have specific reasons to want to closely monitor the state of ICE gathering.
RTCPeerConnection.onicegatheringstatechange = eventHandler;
A function you provide which is passed a single parameter: an
事件
object containing the
icegatheringstatechange
event. You can determine the new state of ICE gathering by looking at the value of the
RTCPeerConnection.iceGatheringState
特性。
This example updates status information presented to the user to let them know what's happening by examining the current value of the
iceGatheringState
property each time it changes and changing the contents of a status display based on the new information.
The status is simply presented as text in a
<div>
元素:
<div id="iceStatus"></div>
The actual event handler looks like this:
pc.onicegatheringstatechange = function() {
let label = "Unknown";
switch(pc.iceGatheringState) {
case "new":
case "complete":
label = "Idle";
break;
case "gathering":
label = "Determining route";
break;
}
document.getElementById("iceStatus").innerHTML = label;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.onicegatheringstatechange' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onicegatheringstatechange
|
Chrome 59 | Edge 15 | Firefox 22 | IE No |
Opera
43
|
Safari 11 | WebView Android 59 | Chrome Android 59 | Firefox Android 44 |
Opera Android
43
|
Safari iOS Yes | Samsung Internet Android 7.0 |
完整支持
不支持
见实现注意事项。
icegatheringstatechange
event and its type,
事件
.
RTCPeerConnection.iceGatheringState
RTCPeerConnection
canTrickleIceCandidates
connectionState
currentLocalDescription
currentRemoteDescription
getDefaultIceServers()
iceConnectionState
iceGatheringState
localDescription
onaddstream
onconnectionstatechange
ondatachannel
onicecandidate
oniceconnectionstatechange
onicegatheringstatechange
onidentityresult
onidpassertionerror
onidpvalidationerror
onnegotiationneeded
onpeeridentity
onremovestream
onsignalingstatechange
ontrack
peerIdentity
pendingLocalDescription
pendingRemoteDescription
remoteDescription
sctp
signalingState
addIceCandidate()
addStream()
addTrack()
close()
createAnswer()
createDataChannel()
createOffer()
generateCertificate()
getConfiguration()
getIdentityAssertion()
getReceivers()
getSenders()
getStats()
getStreamById()
getTransceivers()
removeStream()
removeTrack()
restartIce()
setConfiguration()
setIdentityProvider()
setLocalDescription()
setRemoteDescription()
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent