Skip to main content

remoteTrackStarted

Emitted when any participant in the meeting room shares their microphone, camera, or screen

This event is emitted when any remote participant in the meeting room shares their microphone, camera, or screen.

This event is used to show the remote participant's video or audio to the current user.

JavaScript
meeting.on("remoteTrackStarted", function(remoteTrackItem) {


});

Properties

remoteTrackItem is an object that contains the following properties:

PropertyDescription
streamIduniqueId of the video or audio stream
typetype can be video or audio
participantSessionIdparticipantSessionId of the source Participant
trackMediaStreamTrack . This should be converted into MediaStream object before attaching to html video tag. see example below.
namename of the source user
isComposedStreamcan be true or false

Example

JavaScript
<div id="remoteVideoContainer">
</div>
JavaScript
meeting.on("remoteTrackStarted", function(remoteTrackItem) {
console.log("remoteTrackStarted", remoteTrackItem);
// Converting MediaStreamTrack to MediaStream
var track = remoteTrackItem.track;
var stream = new MediaStream([track]);

// Creating a videoTag to show the remote stream
const videoTag = document.createElement("video");
videoTag.autoplay = true;
videoTag.srcObject = stream;
videoTag.playsinline = true;
// We are setting the id of the videoTag to the streamId
// So that when this track is stopped we can remove the
// videoTag from the page.
videoTag.id = remoteTrackItem.streamId;
// Setting the class name to participantSessionId so that when this participant
// leaves we can easily remove all the video tags associated with this
// participant.
videoTag.class = remoteTrackItem.participantSessionId;

// Adding the video tag to container where we will display
// All the remote streams
$("#remoteVideoContainer").append(videoTag);
});