shareCustomVideoTrack(videoTrack)
Share a custom video track in the meeting
caution
join() must be called before calling this method
Call this method to share a custom video track instead of using the default camera. This is useful when you want to share video from a canvas element, a processed video stream, or any other custom video source.
JavaScript
await meeting.shareCustomVideoTrack(videoTrack)
Parameters
| Parameter | Description | Type | Required |
|---|---|---|---|
| videoTrack | A MediaStreamTrack containing video data | MediaStreamTrack | Yes |
Return Value
Returns the provided MediaStreamTrack after it has been shared.
Events Emitted
localTrackStarted- Emitted when sharing video for the first timelocalTrackUpdated- Emitted when replacing an existing video tracklocalTrackStopped- Emitted when the video track ends
Example
Sharing a Canvas Stream
JavaScript
// Get a canvas element
const canvas = document.getElementById('myCanvas');
// Get the video track from canvas
const canvasStream = canvas.captureStream(30); // 30 FPS
const videoTrack = canvasStream.getVideoTracks()[0];
// Share the custom video track
await meeting.shareCustomVideoTrack(videoTrack);
info
If you are already sharing video, calling this method will replace the current video track with the new one without stopping and restarting the video producer.