From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/rtcpeerconnection/removestream/index.html | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 files/zh-cn/web/api/rtcpeerconnection/removestream/index.html (limited to 'files/zh-cn/web/api/rtcpeerconnection/removestream') 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 +--- +

{{APIRef("WebRTC")}}{{SeeCompatTable}}

+ +

RTCPeerConnection.removeStream() 方法用来移除本地音频或视频的 {{domxref("媒体流")}} 。 如果已经发生交互,远程主机可能需要使用一个新的媒体流。

+ +

当 {{domxref("RTCPeerConnection.signalingState", "signalingState")}} 的值为"closed"时,将抛出InvalidStateError异常。当  {{domxref("RTCPeerConnection.signalingState", "signalingState")}} 值为"stable"时, 将触发{{domxref("RTCPeerConnection")}}的 {{event("negotiationneeded")}} 事件。

+ +

语法

+ +
pc.removeStream(mediaStream);
+
+ +

+ 此方法没有返回值。 +

+ +

参数

+ +
+
mediaStream
+
是 {{domxref("MediaStream")}} 类型的表示要移除的媒体流
+
+ +

例子

+ +
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);
+ +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-removeStream-void-MediaStream-stream', 'RTCPeerConnection.removeStream()') }}{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }} [1]{{ CompatVersionUnknown }} [1]{{ CompatNo() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatNo() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+ +

[1] Though this property is not prefixed, the interface it belongs to is.

+ +

扩展阅读

+ + -- cgit v1.2.3-54-g00ecf