diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/rtcpeerconnection/onaddstream | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/rtcpeerconnection/onaddstream')
-rw-r--r-- | files/zh-cn/web/api/rtcpeerconnection/onaddstream/index.html | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/rtcpeerconnection/onaddstream/index.html b/files/zh-cn/web/api/rtcpeerconnection/onaddstream/index.html new file mode 100644 index 0000000000..1c5a04d575 --- /dev/null +++ b/files/zh-cn/web/api/rtcpeerconnection/onaddstream/index.html @@ -0,0 +1,103 @@ +--- +title: RTCPeerConnection.onaddstream +slug: Web/API/RTCPeerConnection/onaddstream +translation_of: Web/API/RTCPeerConnection/onaddstream +--- +<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p> + +<p><code><strong>当类型为</strong></code>{{domxref("MediaStreamEvent")}}的{{event("addstream")}} 事件发生时,通过{{domxref("RTCPeerConnection")}}触发<code><strong>RTCPeerConnection.onaddstream</strong></code> 事件处理函数。当远程媒体流{{domxref("MediaStream")}} 添加到连接后发送事件。当{{domxref("RTCPeerConnection.setRemoteDescription()")}} 后此事件立即被调用而不需要等待SDP交换完成。</p> + +<h2 id="语法">语法</h2> + +<pre class="eval"><em>peerconnection</em>.onaddstream = <em>function</em>; +</pre> + +<h3 id="值">值</h3> + +<ul> + <li><code>function</code> 是用户自定义的一个函数,写法上不带 <code>()</code> 和任何参数,也可以是一个匿名函数,例如 <code>function(event) {...}</code>。事件处理函数通常有个event做参数,类型为 {{domxref("MediaStreamEvent")}}.</li> +</ul> + +<h2 id="例子">例子</h2> + +<pre class="brush: js">pc.onaddstream = function(ev) { alert("onaddstream event detected!"); }; +</pre> + +<h2 id="Specifications" name="Specifications">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-onaddstream', 'RTCPeerConnection.onaddstream') }}</td> + <td>{{ Spec2('WebRTC 1.0') }}</td> + <td>Initial specification.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{ CompatVersionUnknown() }} [1]</td> + <td>{{ CompatVersionUnknown }} [1]</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>Feature</th> + <th>Android</th> + <th>Chrome for Android</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>{{ CompatUnknown() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] Though this property is not prefixed, the interface it belongs to is.</p> + +<h2 id="扩展阅读">扩展阅读</h2> + +<ul> + <li>The {{event("addstream")}} event and its type, {{domxref("MediaStreamEvent")}}.</li> +</ul> |