blob: 38fc5c1920f7ca18f6f0709e6cf48ffeb5b14c4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
---
title: 'RTCPeerConnection: icecandidate event'
slug: Web/Events/icecandidate
translation_of: Web/API/RTCPeerConnection/icecandidate_event
---
<p>{{SeeCompatTable}}</p>
<p>当 {{domxref("RTCPeerConnection")}}通过{{domxref("RTCPeerConnection.setLocalDescription()")}}方法更改本地描述之后,该{{domxref("RTCPeerConnection")}}会抛出<strong><code>icecandidate</code></strong>事件。该事件的监听器需要将更改后的描述信息传送给远端{{domxref("RTCPeerConnection")}},以更新远端的备选源。</p>
<h2 id="使用指南">使用指南</h2>
<p><code>icecandidate</code> 的类型为 {{domxref("RTCPeerIceCandidateEvent")}}, 在以下三种情况下会触发该事件:</p>
<h3 id="分享新的源">分享新的源</h3>
<p><code>触发icecandidate</code>事件的首要原因:当获得新的源之后,需要将该源的信息发送给远端信号服务器,并分发至其他端的{{domxref("RTCPeerConnection")}}。其他{{domxref("RTCPeerConnection")}}通过{{domxref("RTCPeerConnection.addIceCandidate", "addIceCandidate()")}}方法将新{{domxref("RTCPeerCandidateIceEvent.candidate", "candidate")}} 中携带的信息,将新的源描述信息添加进它的备选池中;</p>
<pre>rtcPeerConnection.onicecandidate = (event) => {
if (event.candidate) {
sendCandidateToRemotePeer(event.candidate)
}
}
</pre>
<h2 id="概述">概述</h2>
<dl>
<dt style="float: left; text-align: right; width: 120px;">规范</dt>
<dd style="margin: 0 0 0 120px;">{{ SpecName('WebRTC 1.0', '#event-mediastream-icecandidate', 'icecandidate') }}</dd>
<dt style="float: left; text-align: right; width: 120px;">接口</dt>
<dd style="margin: 0 0 0 120px;">{{domxref("RTCPeerConnectionIceEvent")}}</dd>
<dt style="float: left; text-align: right; width: 120px;">事件冒泡</dt>
<dd style="margin: 0 0 0 120px;">否</dd>
<dt style="float: left; text-align: right; width: 120px;">能否取消默认</dt>
<dd style="margin: 0 0 0 120px;">否</dd>
<dt style="float: left; text-align: right; width: 120px;">事件目标</dt>
<dd style="margin: 0 0 0 120px;">{{domxref("RTCPeerConnection")}}</dd>
<dt style="float: left; text-align: right; width: 120px;">默认行为</dt>
<dd style="margin: 0 0 0 120px;">无</dd>
</dl>
<h2 id="属性">属性</h2>
<p><em>属性继承自{{domxref("RTCPeerConnectionIceEvent")}}.</em></p>
<h2 id="方法">方法</h2>
<p><em>方法继承自 {{domxref("RTCPeerConnectionIceEvent")}}.</em></p>
<h2 id="相关事件">相关事件</h2>
<ul>
<li><em>无</em></li>
</ul>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">注释</th>
</tr>
<tr>
<td>{{ SpecName('WebRTC 1.0', '#event-mediastream-icecandidate', 'icecandidate') }}</td>
<td>{{Spec2('WebRTC 1.0')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="兼容性">兼容性</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>特性</th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{ CompatVersionUnknown }}</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>特性</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Edge</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="参阅">参阅</h2>
<ul>
<li><a href="/en-US/docs/Web/Guide/API/WebRTC" title="/en-US/docs/CSS/Using_CSS_animations">WebRTC</a></li>
</ul>
|