Properties:
Name | Type | Description |
---|---|---|
audioTrackPublications |
Map.<Track.SID, LocalAudioTrackPublication> | |
audioTracks |
Map.<Track.ID, LocalAudioTrack> | The LocalParticipant's LocalAudioTracks |
dataTrackPublications |
Map.<Track.SID, LocalDataTrackPublication> | |
dataTracks |
Map.<Track.ID, LocalDataTrack> | The LocalParticipant's LocalDataTracks |
trackPublications |
Map.<Track.SID, LocalTrackPublication> | |
tracks |
Map.<Track.ID, LocalTrack> | The LocalParticipant's LocalTracks |
videoTrackPublications |
Map.<Track.SID, LocalVideoTrackPublication> | |
videoTracks |
Map.<Track.ID, LocalVideoTrack> | The LocalParticipant's LocalVideoTracks |
Fires:
- LocalParticipant#event:trackAdded
- LocalParticipant#event:trackDimensionsChanged
- LocalParticipant#event:trackDisabled
- LocalParticipant#event:trackEnabled
- LocalParticipant#event:trackPublicationFailed
- LocalParticipant#event:trackPublished
- LocalParticipant#event:trackRemoved
- LocalParticipant#event:trackStarted
- LocalParticipant#event:trackStopped
Extends
Methods
-
addTrack(track)
-
Adds a LocalTrack to the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack | MediaStreamTrack The LocalTrack to add; if a MediaStreamTrack is provided, and a corresponding LocalTrack has not yet been added, this method will construct one
- Deprecated:
-
- Use LocalParticipant#publishTrack instead
Fires:
Throws:
TypeErrorReturns:
- The LocalTrack if added, null if already present
- Type
- LocalTrack
-
addTracks(tracks)
-
Adds multiple LocalTracks to the LocalParticipant.
Parameters:
Name Type Description tracks
Array.<(LocalTrack|MediaStreamTrack)> The LocalTracks to add; for any MediaStreamTracks provided, if a corresponding LocalAudioTrack or LocalVideoTrack has not yet been added, this method will construct one
- Deprecated:
-
- Use LocalParticipant#publishTracks instead
Fires:
Throws:
TypeErrorReturns:
- The LocalTracks that were successfully added; if the LocalParticipant already has a LocalTrack, it won't be included in the Array
- Type
- Array.<LocalTrack>
-
publishTrack(localTrack)
-
Publishes a LocalTrack to the Room.
Parameters:
Name Type Description localTrack
LocalTrack The LocalTrack to publish
Fires:
Returns:
- Resolves with the corresponding LocalTrackPublication if successful
- Type
- Promise.<LocalTrackPublication>
-
publishTrack(mediaStreamTrack [, options])
-
Publishes a MediaStreamTrack to the Room.
Parameters:
Name Type Argument Description mediaStreamTrack
MediaStreamTrack The MediaStreamTrack to publish; if a corresponding LocalAudioTrack or LocalVideoTrack has not yet been published, this method will construct one
options
LocalTrackOptions <optional>
The LocalTrackOptions for constructing the MediaStreamTrack's corresponding LocalAudioTrack or LocalVideoTrack
Fires:
Returns:
- Resolves with the corresponding LocalTrackPublication if successful
- Type
- Promise.<LocalTrackPublication>
Example
var Video = require('twilio-video'); Video.connect(token, { name: 'my-cool-room', audio: true }).then(function(room) { // Publish a video MediaStreamTrack with a custom name return room.localParticipant.publishTrack(mediaStreamTrack, { name: 'camera' }); }).then(function(publication) { console.log('The LocalTrack "' + publication.trackName + '" was successfully published'); });
-
publishTracks(tracks)
-
Publishes multiple LocalTracks to the Room.
Parameters:
Name Type Description tracks
Array.<(LocalTrack|MediaStreamTrack)> The LocalTracks to publish; for any MediaStreamTracks provided, if a corresponding LocalAudioTrack or LocalVideoTrack has not yet been published, this method will construct one
Fires:
Throws:
TypeErrorReturns:
- The resulting LocalTrackPublications
- Type
- Promise.<Array.<LocalTrackPublication>>
-
removeTrack(track [, stop])
-
Removes a LocalTrack from the LocalParticipant.
Parameters:
Name Type Argument Default Description track
LocalTrack | MediaStreamTrack The LocalTrack to remove; if a MediaStreamTrack is provided, this method looks up the corresponding LocalAudioTrack or LocalVideoTrack to remove
stop
boolean <optional>
<nullable>
true Whether or not to call LocalAudioTrack#stop or LocalVideoTrack#stop
- Deprecated:
-
- Use LocalParticipant#unpublishTrack instead
Fires:
Throws:
TypeErrorReturns:
- The LocalTrack removed, otherwise null
- Type
- LocalTrack
-
removeTracks(tracks [, stop])
-
Removes multiple LocalTracks from the LocalParticipant.
Parameters:
Name Type Argument Default Description tracks
Array.<(LocalTrack|MediaStreamTrack)> The LocalTracks to remove; for any MediaStreamTracks provided, this method looks up the corresponding LocalAudioTrack or LocalVideoTrack to remove
stop
boolean <optional>
<nullable>
true Whether or not to call LocalAudioTrack#stop or LocalVideoTrack#stop on each LocalAudioTrack or LocalVideoTrack that was successfully removed
- Deprecated:
-
- Use LocalParticipant#unpublishTracks instead
Fires:
Throws:
TypeErrorReturns:
- The LocalTracks that were successfully removed
- Type
- Array.<LocalTrack>
-
setNetworkQualityConfiguration(networkQualityConfiguration)
-
Sets the NetworkQualityVerbosity for the LocalParticipant and RemoteParticipants. It does nothing if Network Quality is not enabled while calling connect.
Parameters:
Name Type Description networkQualityConfiguration
NetworkQualityConfiguration The new NetworkQualityConfiguration; If either or both of the local and remote NetworkQualityVerbosity values are absent, then the corresponding existing values are retained
Returns:
- Type
- this
Examples
// Update verbosity levels for both LocalParticipant and RemoteParticipants localParticipant.setNetworkQualityConfiguration({ local: 1, remote: 2 });
// Update verbosity level for only the LocalParticipant localParticipant.setNetworkQualityConfiguration({ local: 1 });
// Update verbosity level for only the RemoteParticipants localParticipant.setNetworkQualityConfiguration({ remote: 2 });
-
setParameters( [encodingParameters])
-
Set the LocalParticipant's EncodingParameters.
Parameters:
Name Type Argument Description encodingParameters
EncodingParameters <optional>
<nullable>
The new EncodingParameters; If null, then the bitrate limits are removed; If not specified, then the existing bitrate limits are preserved
Throws:
TypeErrorReturns:
- Type
- this
-
unpublishTrack(track)
-
Stops publishing a LocalTrack to the Room.
Parameters:
Name Type Description track
LocalTrack | MediaStreamTrack The LocalTrack to stop publishing; if a MediaStreamTrack is provided, this method looks up the corresponding LocalAudioTrack or LocalVideoTrack to stop publishing
Fires:
Throws:
TypeErrorReturns:
- The corresponding LocalTrackPublication if the LocalTrack was previously published, null otherwise
-
unpublishTracks(tracks)
-
Stops publishing multiple LocalTracks to the Room.
Parameters:
Name Type Description tracks
Array.<(LocalTrack|MediaStreamTrack)> The LocalTracks to stop publishing; for any MediaStreamTracks provided, this method looks up the corresponding LocalAudioTrack or LocalVideoTrack to stop publishing
Fires:
Throws:
TypeErrorReturns:
- The corresponding LocalTrackPublications that were successfully unpublished
- Type
- Array.<LocalTrackPublication>
Events
-
disconnected
-
The Participant has disconnected.
Parameters:
Name Type Description participant
Participant The Participant that disconnected.
- Inherited From:
- Overrides:
-
networkQualityLevelChanged
-
The Participant's NetworkQualityLevel changed.
Parameters:
Name Type Argument Description networkQualityLevel
NetworkQualityLevel The new NetworkQualityLevel
networkQualityStats
NetworkQualityStats <nullable>
The NetworkQualityStats based on which NetworkQualityLevel is calculated, if any
- Inherited From:
- Overrides:
-
trackAdded
-
A LocalTrack was added by the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that was added
- Overrides:
- Deprecated:
-
- If you are using this event to monitor LocalTracks that are published to the Room, alternatively you can access the .tracks collection which contains the newly added LocalTracks right after LocalParticipant#publishTrack(s) is called
-
trackDimensionsChanged
-
One of the LocalParticipant's LocalVideoTrack's dimensions changed.
Parameters:
Name Type Description track
LocalVideoTrack The LocalVideoTrack whose dimensions changed
- Overrides:
-
trackDisabled
-
A LocalTrack was disabled by the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that was disabled
- Overrides:
-
trackEnabled
-
A LocalTrack was enabled by the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that was enabled
- Overrides:
-
trackPublicationFailed
-
A LocalTrack failed to publish. Check the error message for more information.
Parameters:
Name Type Description error
TwilioError A TwilioError explaining why publication failed
localTrack
LocalTrack The LocalTrack that failed to publish
-
trackPublished
-
A LocalTrack was successfully published.
Parameters:
Name Type Description publication
LocalTrackPublication The resulting LocalTrackPublication for the published LocalTrack
-
trackRemoved
-
A LocalTrack was removed by the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that was removed
- Overrides:
- Deprecated:
-
- If you are using this event to monitor LocalTracks that are unpublished from the Room, alternatively you can monitor the return value of LocalParticipant#unpublishTrack(s), which is the removed LocalTrack(s)
-
trackStarted
-
One of the LocalParticipant's LocalTracks started.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that started
- Overrides:
-
trackStopped
-
One of the LocalParticipant's LocalTracks stopped, either because LocalTrack#stop was called or because the underlying MediaStreamTrack ended).
Parameters:
Name Type Description track
LocalTrack The LocalTrack that stopped