new LocalVideoTrack(mediaStreamTrack [, options])
Construct a LocalVideoTrack from a MediaStreamTrack.
Extends:
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
mediaStreamTrack |
MediaStreamTrack | The underlying MediaStreamTrack |
|
options |
LocalTrackOptions |
<optional> |
LocalTrack options |
Properties:
Name | Type | Description |
---|---|---|
isStopped |
boolean | Whether or not the LocalVideoTrack is stopped |
Fires:
Extends
Members
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( [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
-
enable()
-
Enable the LocalVideoTrack. This is effectively "unpause".
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 VideoTrack was disabled, i.e. "paused".
Parameters:
Name Type Description track
VideoTrack The VideoTrack that was disabled
- Inherited From:
- Overrides:
-
enabled
-
The VideoTrack was enabled, i.e. "unpaused".
Parameters:
Name Type Description track
VideoTrack The VideoTrack that was enabled
- Inherited From:
- Overrides:
-
started
-
The VideoTrack started. This means there is enough video data to begin playback.
Parameters:
Name Type Description track
VideoTrack The VideoTrack that started
- Inherited From:
- Overrides: