Skip to main content

composedTrackStarted

When the composition is enabled, the composed media stream is received by this event.

This event is emitted when a user joins a meeting room with composition enabled.

JavaScript
meeting.on("composedTrackStarted", 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
isComposedStreamtrue

Example

JavaScript
<div id="remoteVideoContainer">
</div>
JavaScript
meeting.on("composedTrackStarted", function(remoteTrackItem) {
console.log("composedTrackStarted", 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);
});