RTCPeerConnection.removeStream()
RTCPeerConnection.removeStream()
方法用来移除本地音频或视频的 媒体流
。如果已经发生交互,远程主机可能需要使用一个新的媒体流。
当 signalingState
的值为 "closed"
时,将抛出InvalidStateError
异常。当 signalingState
值为 "stable"
时,将触发 RTCPeerConnection
的 negotiationneeded
事件。
语法
pc.removeStream(mediaStream);
此方法没有返回值。
参数
- mediaStream
-
是
MediaStream
类型的表示要移除的媒体流
示例
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);
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
removeStream |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Non-standard. Check cross-browser support before using.
- Deprecated. Not for use in new websites.
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.