localTrackStarted
Emitted when startAudio() startVideo() or startScreenSharing() method is called
This event is emitted when any of the following methods are called:
startAudio()
startVideo()
startScreenSharing()
JavaScript
meeting.on("localTrackStarted", function(localTrackItem) {
});
Properties
localTrackItem
is an object that contain the following properties
Property | Description | Type |
---|---|---|
type | type can be audio or video | string |
streamId | unique streamId associated with the stream. | string |
track | MediaStreamTrack to add to a video tag you would need to convert it into a MediaStream object. see the example below. | object |
Example
JavaScript
<video id="localvideo" autoplay muted></video>
JavaScript
meeting.on("localTrackStarted", function(localTrackItem) {
if (item.type === "video") {
/**
* localTrackStarted event emits a MediaStreamTrack
* but we cannot assign MediaStreamTrack into the html video tag
* hence we are creating MediaStream object, a MediaStream
* can be assigned to the html video tag.
*/
var track = item.track;
var mediaStream = new MediaStream([track]);
/**
* We have a video tag on the page with id
* localvideo
* e.g: <video id="localvideo" autoplay muted></video>
* This video tag will show the user their own video
*/
document.getElementById("localvideo").srcObject = mediaStream;
document.getElementById("localvideo").play();
}
});