W3cubDocs

/Web APIs

RTCTrackEvent: RTCTrackEvent() constructor

The RTCTrackEvent() constructor creates and returns a new RTCTrackEvent object, configured to describe the track which has been added to the RTCPeerConnection.

In general, you won't need to use this constructor, as RTCTrackEvent objects are created by WebRTC and delivered to your RTCPeerConnector's ontrack event handler as appropriate.

Syntax

js

new RTCTrackEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers always set it to track.

options

An object that, in addition of the properties defined in Event(), can have the following properties:

receiver

The RTCRtpReceiver which is being used to receive the track's media.

streams Optional

An array of MediaStream objects representing each of the streams that comprise the event's corresponding track. It defaults to an empty array.

track

The MediaStreamTrack the event is associated with.

transceiver

The RTCRtpTransceiver associated with the event.

Return value

A new RTCTrackEvent describing a track which has been added to the RTCPeerConnection.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
RTCTrackEvent 64 79 46 No 51 11 64 64 46 47 11 9.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCTrackEvent/RTCTrackEvent