RTCPeerConnection.getSenders() - Web APIs 编辑
The RTCPeerConnection
method 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.
Syntax
var senders = rtcPeerConnection.getSenders();
Return value
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.
Example
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;
}
}
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCPeerConnection.getSenders()' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论