diff options
Diffstat (limited to 'files/zh-cn/web/api/rtcpeerconnection/removestream/index.html')
-rw-r--r-- | files/zh-cn/web/api/rtcpeerconnection/removestream/index.html | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/rtcpeerconnection/removestream/index.html b/files/zh-cn/web/api/rtcpeerconnection/removestream/index.html new file mode 100644 index 0000000000..d8934b29c9 --- /dev/null +++ b/files/zh-cn/web/api/rtcpeerconnection/removestream/index.html @@ -0,0 +1,118 @@ +--- +title: RTCPeerConnection.removeStream() +slug: Web/API/RTCPeerConnection/removeStream +translation_of: Web/API/RTCPeerConnection/removeStream +--- +<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p> + +<p><code><strong>RTCPeerConnection.removeStream()</strong></code> 方法用来移除本地音频或视频的 {{domxref("媒体流")}} 。 如果已经发生交互,远程主机可能需要使用一个新的媒体流。</p> + +<p>当 {{domxref("RTCPeerConnection.signalingState", "signalingState")}} 的值为<code>"closed"时,将抛出</code><code>InvalidStateError异常。当</code> {{domxref("RTCPeerConnection.signalingState", "signalingState")}} 值为<code>"stable"时,</code> 将触发{{domxref("RTCPeerConnection")}}的 {{event("negotiationneeded")}} 事件。</p> + +<h2 id="Syntax" name="Syntax">语法</h2> + +<pre class="syntaxbox"><code><em>pc</em>.removeStream(<em>mediaStream</em>); +</code></pre> + +<p> + <i>此方法没有返回值。</i> +</p> + +<h3 id="Example" name="Example">参数</h3> + +<dl> + <dt><em>mediaStream</em></dt> + <dd>是 {{domxref("MediaStream")}} 类型的表示要移除的媒体流</dd> +</dl> + +<h2 id="Example" name="Example">例子</h2> + +<pre class="brush: js">var pc, videoStream; +navigator.getUserMedia({video: true}, function(stream) { + pc = new RTCPeerConnection(); + videoStream = stream; + pc.addStream(stream); +} +document.getElementById("closeButton").addEventListener("click", function(event) { + pc.removeStream(videoStream); + pc.close(); +}, false);</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-removeStream-void-MediaStream-stream', 'RTCPeerConnection.removeStream()') }}</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><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li> +</ul> |