RTCPeerConnection: getSenders() method

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

The getSenders() method of the RTCPeerConnection interface 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

js
getSenders()

Parameters

None.

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 instances is not defined by the specification, and may change from one call to getSenders() to the next.

The array does not include senders associated with transceivers that have been stopped (following offer/answer).

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.

js
function setMuting(pc, muting) {
  let senderList = pc.getSenders();

  senderList.forEach((sender) => {
    sender.track.enabled = !muting;
  });
}

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-peerconnection-getsenders

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getSenders
Chrome – Full support
Chrome 64 (Release date: 2018-01-23)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 34 (Release date: 2014-12-01)
footnote Full support
Opera – Full support
Opera 51 (Release date: 2018-02-07)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 64 (Release date: 2018-01-23)
footnote Full support
Firefox for Android – Full support
Firefox for Android 34 (Release date: 2014-12-01)
footnote Full support
Opera Android – Full support
Opera Android 47 (Release date: 2018-07-23)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 6 (Release date: 2017-08-23)
footnote Full support
WebView Android – Full support
WebView Android 64 (Release date: 2018-01-23)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
Senders for stopped transceivers not returned
Chrome – Full support
Chrome 88 (Release date: 2021-01-19)
footnote Full support
Edge – Full support
Edge 88 (Release date: 2021-01-21)
footnote Full support
Firefox – Full support
Firefox 118 (Release date: 2023-09-26)
footnote Full support
Opera – Full support
Opera 74 (Release date: 2021-02-02)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 88 (Release date: 2021-01-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 118 (Release date: 2023-09-26)
footnote Full support
Opera Android – Full support
Opera Android 63 (Release date: 2021-04-16)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 15 (Release date: 2021-08-13)
footnote Full support
WebView Android – Full support
WebView Android 88 (Release date: 2021-01-19)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also