RTCPeerConnection 方法 getSenders() returns an array of RTCRtpSender objects, each of which represents the RTP sender responsible for transmitting one track's data. A sender object provides methods and properties for examining and controlling the encoding and transmission of the track's data.

句法

var senders = rtcPeerConnection.getSenders();
					

返回值

An array of RTCRtpSender objects, one for each track on the connection. The array is empty if there are no RTP senders on the connection.

The order of the returned RTCRtpSender s is not defined by the specification, and may change from one call to getSenders() to the next.

范例

In this example, a setMuting() function is shown. This function takes as input an RTCPeerConnection , pc , and a Boolean, muting . The function gets the list of the peer connection's senders and iterates over every sender, setting the corresponding media track's enabled to the inverse of the specified muting .

function setMuting(pc, muting) {
  let senderList = pc.getSenders();
  senderList.forEach(sender) {
    sender.track.enabled = !muting;
  }
}
					

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.getSenders()' in that specification.
候选推荐 最初的规范。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getSenders Chrome 64 Edge ≤18 Firefox 22 IE No Opera 51 Safari 11 WebView Android 64 Chrome Android 64 Firefox Android 44 Opera Android 47 Safari iOS Yes Samsung Internet Android 6.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: