RTCPeerConnection: addstream event

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

The obsolete addstream event is sent to an RTCPeerConnection when new media, in the form of a MediaStream object, has been added to it.

Important: This event has been removed from the WebRTC specification. You should instead watch for the track event, which is sent for each media track added to the RTCPeerConnection.

Bubbles No
Cancelable No
Interface MediaStreamEvent
Event handler property RTCPeerconnection.onaddstream

You can, similarly, watch for streams to be removed from the connection by monitoring the removestream event.


This example looks to determine if the user's browser supports the track event. If it does, a track event listener is set up; otherwise, an addstream event listener is set up. pc is an RTCPeerConnection.

if (pc.addTrack !== undefined) {
  pc.ontrack = ev => {
    ev.streams.forEach(stream => doAddStream(stream));
} else {
  pc.onaddstream = ev => {

This calls a function doAddStream() once for each stream being added to the RTCPeerConnection, regardless of whether the browser sends addstream or track.

You can also use the addEventListener() method to set an event listener:

pc.addEventListener("addstream", ev => doAddStream(ev.stream), false);

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
addstream event
Chrome Full support 24Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 43Safari No support NoWebView Android Full support YesChrome Android Full support 25Firefox Android Full support 44Opera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also