replaceTrack method

JSPromise<JSAny?> replaceTrack(
  1. MediaStreamTrack? withTrack
)

The RTCRtpSender method replaceTrack() replaces the track currently being used as the sender's source with a new MediaStreamTrack.

The new track must be of the same media kind (audio, video, etc.) and switching the track should not require negotiation.

Among the use cases for replaceTrack() is the common need to switch between the rear- and front-facing cameras on a phone. With replaceTrack(), you can have a track object for each camera and switch between the two as needed. See the example Switching cameras below.

Implementation

external JSPromise<JSAny?> replaceTrack(MediaStreamTrack? withTrack);