Skip to main content

localTrackUpdated

Emitted when an existing local track is replaced with a new track

This event is emitted when an existing local track is replaced with a new track. This can occur when:

  • shareCustomVideoTrack() is called while already sharing video
  • chooseAudioInputDevice() is called to switch audio input devices during an active meeting
  • chooseVideoInputDevice() is called to switch video input devices during an active meeting
  • startVideo() is called while screen sharing (replaces screen with camera)
  • startScreenShare() is called while sharing video (replaces camera with screen)
JavaScript
meeting.on("localTrackUpdated", function(localTrackItem) {

});

Properties

localTrackItem is an object that contains the following properties

PropertyDescriptionType
typetype can be audio or videostring
streamIdunique streamId associated with the streamstring
trackMediaStreamTrack to add to a video tag you would need to convert it into a MediaStream objectobject

Example

JavaScript
meeting.on("localTrackUpdated", function(localTrackItem) {
if (localTrackItem.type === "video") {
// Update the video element with the new track
var track = localTrackItem.track;
var mediaStream = new MediaStream([track]);
document.getElementById("localvideo").srcObject = mediaStream;
}
});