Class: LocalParticipant

LocalParticipant

A LocalParticipant represents the local Participant in a Room.

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:
Fires:
Throws:
TypeError
Returns:
  • 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:
Fires:
Throws:
TypeError
Returns:
Type
Array.<LocalTrack>

publishTrack(localTrack)

Publishes a LocalTrack to the Room.

Parameters:
Name Type Description
localTrack LocalTrack

The LocalTrack to publish

Fires:
Returns:
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:
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:
TypeError
Returns:
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:
Fires:
Throws:
TypeError
Returns:
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:
Fires:
Throws:
TypeError
Returns:
Type
Array.<LocalTrack>

setParameters( [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:
TypeError
Returns:
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:
TypeError
Returns:
Type
LocalTrackPublication

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:
TypeError
Returns:
Type
Array.<LocalTrackPublication>

Events


disconnected

The Participant has disconnected.

Parameters:
Name Type Description
participant Participant

The Participant that disconnected.

Inherited From:

trackAdded

A LocalTrack was added by the LocalParticipant.

Parameters:
Name Type Description
track LocalTrack

The LocalTrack that was added

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

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:

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