RTCTrackEvent: RTCTrackEvent() constructor
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.
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 RTCPeerConnection's
ontrack event handler as appropriate.
Syntax
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
RTCRtpReceiverwhich is being used to receive the track's media. streamsOptional-
An array of
MediaStreamobjects representing each of the streams that comprise the event's corresponding track. It defaults to an empty array. track-
The
MediaStreamTrackthe event is associated with. transceiver-
The
RTCRtpTransceiverassociated with the event.
Return value
A new RTCTrackEvent describing a track which has been added to the
RTCPeerConnection.
Specifications
| Specification |
|---|
| WebRTC: Real-Time Communication in Browsers> # dom-rtctrackevent-constructor> |
Browser compatibility
Loading…