Class: LocalVideoTrack

LocalVideoTrack

A LocalVideoTrack is a VideoTrack representing video that your LocalParticipant can publish to a Room. It can be enabled and disabled with LocalVideoTrack#enable and LocalVideoTrack#disable or stopped completely with LocalVideoTrack#stop.


new Twilio.Video.LocalVideoTrack(mediaStreamTrack [, options])

Construct a LocalVideoTrack from a MediaStreamTrack.

Parameters:
Name Type Argument Description
mediaStreamTrack MediaStreamTrack

The underlying MediaStreamTrack

options LocalTrackOptions <optional>

LocalTrack options

Properties:
Name Type Description
id Track.ID

The LocalVideoTrack's ID

isStopped boolean

Whether or not the LocalVideoTrack is stopped

Fires:

Extends

Methods


attach()

Create an HTMLVideoElement and attach the VideoTrack to it.

The HTMLVideoElement's srcObject will be set to a new MediaStream containing the VideoTrack's MediaStreamTrack.

Inherited From:
Overrides:
Returns:

videoElement

Type
HTMLVideoElement
Example
const Video = require('twilio-video');

Video.createLocalVideoTrack().then(function(videoTrack) {
  const videoElement = videoTrack.attach();
  document.body.appendChild(videoElement);
});
  

detach()

Detach the VideoTrack from all previously attached HTMLMediaElements.

Inherited From:
Overrides:
Returns:

mediaElements

Type
Array.<HTMLMediaElement>
Example
const mediaElements = videoTrack.detach();
mediaElements.forEach(mediaElement => mediaElement.remove());
  

disable()

Disable the LocalVideoTrack. This is effectively "pause".

Fires:
Returns:
Type
this

enable()

Enable the LocalVideoTrack. This is effectively "unpause".

Fires:
Returns:
Type
this

enable( [enabled])

Enable or disable the LocalVideoTrack. This is effectively "unpause" or "pause".

Parameters:
Name Type Argument Description
enabled boolean <optional>

Specify false to pause the LocalVideoTrack

Fires:
Returns:
Type
this

stop()

Calls stop on the underlying MediaStreamTrack. If you choose to stop a LocalVideoTrack, you should unpublish it after stopping.

Fires:
Returns:
Type
this

Events


dimensionsChanged

The VideoTrack's dimensions changed.

Parameters:
Name Type Description
track VideoTrack

The VideoTrack whose dimensions changed

Inherited From:
Overrides:

disabled

The LocalVideoTrack was disabled, i.e. "muted".

Parameters:
Name Type Description
track LocalVideoTrack

The LocalVideoTrack that was disabled

Overrides:

enabled

The LocalVideoTrack was enabled, i.e. "unmuted".

Parameters:
Name Type Description
track LocalVideoTrack

The LocalVideoTrack that was enabled

Overrides:

started

The LocalVideoTrack started. This means there is enough video data to begin playback.

Parameters:
Name Type Description
track LocalVideoTrack

The LocalVideoTrack that started

Overrides:

stopped

The LocalVideoTrack stopped, either because LocalVideoTrack#stop was called or because the underlying MediaStreamTrack ended).

Parameters:
Name Type Description
track LocalVideoTrack

The LocalVideoTrack that stopped