diff options
Diffstat (limited to 'files/zh-cn/web/api/rtcpeerconnection/addstream_event/index.html')
-rw-r--r-- | files/zh-cn/web/api/rtcpeerconnection/addstream_event/index.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/rtcpeerconnection/addstream_event/index.html b/files/zh-cn/web/api/rtcpeerconnection/addstream_event/index.html new file mode 100644 index 0000000000..25483657c8 --- /dev/null +++ b/files/zh-cn/web/api/rtcpeerconnection/addstream_event/index.html @@ -0,0 +1,54 @@ +--- +title: RTCPeerConnection.onaddstream +slug: Web/API/RTCPeerConnection/addstream_event +translation_of: Web/API/RTCPeerConnection/onaddstream +original_slug: 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> + +{{Compat("api.RTCPeerConnection.onaddstream")}} + +<h2 id="扩展阅读">扩展阅读</h2> + +<ul> + <li>The {{event("addstream")}} event and its type, {{domxref("MediaStreamEvent")}}.</li> +</ul> |