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.

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


});

Properties

remoteTrackItem is an object that contains the following properties:

Property

Description

streamId

uniqueId of the video or audio stream

type

type can be video or audio

participantSessionId

participantSessionId of the source Participant

track

MediaStreamTrack. This should be converted into MediaStream object before attaching to html video tag. see example below.

name

name of the source user

Example

<div id="remoteVideoContainer">
</div>
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);
});