Properties:
Name | Type | Description |
---|---|---|
audioTracks |
Map.<Track.SID, LocalAudioTrackPublication> | |
dataTracks |
Map.<Track.SID, LocalDataTrackPublication> | |
tracks |
Map.<Track.SID, LocalTrackPublication> | |
videoTracks |
Map.<Track.SID, LocalVideoTrackPublication> | |
signalingRegion |
string | The geographical region of the signaling edge the LocalParticipant is connected to. |
Fires:
- RemoteParticipant#event:reconnected
- RemoteParticipant#event:reconnecting
- LocalParticipant#event:trackDimensionsChanged
- LocalParticipant#event:trackDisabled
- LocalParticipant#event:trackEnabled
- LocalParticipant#event:trackPublicationFailed
- LocalParticipant#event:trackPublished
- LocalParticipant#event:trackStarted
- LocalParticipant#event:trackStopped
Extends
Methods
-
publishTrack(localTrack [, options])
-
Publishes a LocalTrack to the Room.
Parameters:
Name Type Argument Description localTrack
LocalTrack The LocalTrack to publish
options
LocalTrackPublishOptions <optional>
The LocalTrackPublishOptions for publishing the LocalTrack
Throws:
-
TypeError
-
RangeError
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) { return Video.createLocalVideoTrack({ name: 'camera' }).then(function(localVideoTrack) { return room.localParticipant.publishTrack(localVideoTrack, { priority: 'high' }); }); }).then(function(publication) { console.log('The LocalTrack "' + publication.trackName + '" was successfully published with priority "' * publication.priority + '"'); });
-
-
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
MediaStreamTrackPublishOptions <optional>
The options for publishing the MediaStreamTrack
Throws:
-
TypeError
-
RangeError
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) { return navigator.mediaDevices.getUserMedia({ video: true }).then(function(mediaStream) { var mediaStreamTrack = mediaStream.getTracks()[0]; return room.localParticipant.publishTrack(mediaStreamTrack, { name: 'camera', priority: 'high' }); }); }).then(function(publication) { console.log('The LocalTrack "' + publication.trackName + '" was successfully published with priority "' * publication.priority + '"'); });
-
-
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
Throws:
TypeErrorReturns:
- The resulting LocalTrackPublications
- Type
- Promise.<Array.<LocalTrackPublication>>
-
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
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
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:
-
reconnected
-
The LocalParticipant has reconnected to the Room after a signaling connection disruption.
- Overrides:
-
reconnecting
-
The LocalParticipant is reconnecting to the Room after a signaling connection disruption.
- Overrides:
-
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
-
trackEnabled
-
A LocalTrack was enabled by the LocalParticipant.
Parameters:
Name Type Description track
LocalTrack The LocalTrack that was enabled
-
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
-
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