new Twilio.Video.LocalMedia()
Construct a LocalMedia object.
Properties:
Name | Type | Description |
---|---|---|
audioTracks |
Map.<Track.ID, LocalAudioTrack> | The LocalAudioTracks on this Media object |
tracks |
Map.<Track.ID, LocalTrack> | The LocalAudioTracks and LocalVideoTracks on this Media object |
videoTracks |
Map.<Track.ID, LocalVideoTrack> | The LocalVideoTracks on this Media object |
Extends
Methods
-
<static> getLocalMedia( [options])
-
Get LocalMedia. By default, this requests a LocalAudioTrack and a LocalVideoTrack representing a microphone and camera.
This method callsgetUserMedia
internally. Pass inoptions
to override the default behavior.Parameters:
Name Type Argument Default Description options
LocalMedia.GetLocalMediaOptions <optional>
<nullable>
{audio:true,video:true} Options to override LocalMedia.getLocalMedia's default behavior
Returns:
- Type
- Promise.<LocalMedia>
-
addCamera( [videoConstraints])
-
Adds a LocalVideoTrack representing your browser's camera to the LocalMedia object, if not already added.
Internally, this callsgetUserMedia({ video: true })
.Parameters:
Name Type Argument Description videoConstraints
MediaTrackConstraints <optional>
Fires:
Returns:
- Type
- Promise.<LocalVideoTrack>
-
addMicrophone( [audioConstraints])
-
Adds a LocalAudioTrack representing your browser's microphone to the LocalMedia object, if not already added.
Internally, this callsgetUserMedia({ audio: true })
.Parameters:
Name Type Argument Description audioConstraints
MediaTrackConstraints <optional>
Fires:
Returns:
- Type
- Promise.<LocalAudioTrack>
-
addStream(mediaStream)
-
Add a
MediaStream
to the LocalMedia object, constructing LocalTracks as necessary for eachMediaStreamTrack
contained within.Parameters:
Name Type Description mediaStream
MediaStream The
MediaStream
to addFires:
Returns:
- Type
- this
-
addTrack(track)
-
Adds a LocalTrack to the LocalMedia object, if not already added.
Parameters:
Name Type Description track
LocalTrack The LocalTrack to add
Fires:
Returns:
- Type
- this
-
attach()
-
Attach the Media to a newly created <div> element.
- Inherited From:
- Overrides:
Returns:
- Type
- HTMLElement
Example
var remoteMediaEl = media.attach(); document.getElementById('div#remote-media-container').appendChild(remoteMediaEl);
-
detach()
-
Detach the Media from any and all previously attached HTMLElements.
- Inherited From:
- Overrides:
Returns:
- Type
- Array.<HTMLElement>
Example
var detachedMediaEls = media.detach();
-
mute()
-
Disable every LocalAudioTrack on this LocalMedia object.
Fires:
Returns:
- Type
- this
-
mute(enabled)
-
Disable or enable every LocalAudioTrack on this LocalMedia object.
Parameters:
Name Type Argument Description enabled
boolean <nullable>
Specify false to enable the LocalAudioTracks
Fires:
Returns:
- Type
- this
-
pause()
-
Disable every LocalVideoTrack on this LocalMedia object.
Fires:
Returns:
- Type
- this
-
pause(enabled)
-
Disable or enable every LocalVideoTrack on this LocalMedia object.
Parameters:
Name Type Argument Description enabled
boolean <nullable>
Specify false to enable the LocalVideoTracks
Fires:
Returns:
- Type
- this
-
removeCamera( [stop])
-
Removes the LocalVideoTrack representing your browser's camera, if it has been added.
Parameters:
Name Type Argument Default Description stop
boolean <optional>
<nullable>
true Whether or not to call LocalTrack#stop on the corresponding LocalTrack
Fires:
Returns:
- Type
- LocalVideoTrack
-
removeMicrophone( [stop])
-
Removes the LocalAudioTrack representing your browser's microphone, if it has been added.
Parameters:
Name Type Argument Default Description stop
boolean <optional>
<nullable>
true Whether or not to call LocalTrack#stop on the corresponding LocalTrack
Fires:
Returns:
- Type
- LocalAudioTrack
-
removeStream(mediaStream [, stop])
-
Remove a
MediaStream
from the LocalMedia object. This will remove any LocalTracks corresponding toMediaStreamTrack
s contained within theMediaStream
.Parameters:
Name Type Argument Default Description mediaStream
MediaStream The
MediaStream
to removestop
boolean <optional>
<nullable>
true Whether or not to call LocalTrack#stop on the corresponding LocalTracks
Fires:
Returns:
- Type
- this
-
removeTrack(track [, stop])
-
Removes a LocalTrack from the LocalMedia object, if it was added.
Parameters:
Name Type Argument Default Description track
LocalTrack The LocalTrack to remove
stop
boolean <optional>
<nullable>
true Whether or not to call LocalTrack#stop
Fires:
Returns:
- Type
- this
-
setLogLevel(logLevel)
-
Set log levels for LocalMedia
Parameters:
Name Type Description logLevel
LogLevels | LogLevel New log level(s)
Returns:
this
- Type
- LocalMedia
-
stop()
-
Stop all LocalAudioTracks and LocalVideoTracks on this LocalMedia object.
Returns:
- Type
- this
-
unmute()
-
Enable every LocalAudioTrack on this LocalMedia object.
Fires:
Returns:
- Type
- this
-
unpause()
-
Enable every LocalVideoTrack on this LocalMedia object.
Fires:
Returns:
- Type
- this
Type Definitions
-
GetLocalMediaOptions
-
You may pass these options to LocalMedia.getLocalMedia to override the default behavior.
Type:
- object
Properties:
Name Type Argument Default Description localMedia
LocalMedia <optional>
<nullable>
null Set to reuse an existing LocalMedia object
localStream
MediaStream <optional>
<nullable>
null Set to reuse an existing
MediaStream
audio
boolean <optional>
<nullable>
true Whether or not to get local audio with
getUserMedia
when neitherlocalMedia
norlocalStream
are providedvideo
boolean <optional>
<nullable>
true Whether or not to get local video with
getUserMedia
when neitherlocalMedia
norlocalStream
are provided -
Options
-
You may pass these options to the LocalMedia constructor to override the default behavior.
Type:
- object
Events
-
trackAdded
-
Parameters:
Name Type Description track
Track The Track that was added
- Inherited From:
-
trackDimensionsChanged
-
The dimensions of a VideoTrack on this Media object changed.
Parameters:
Name Type Description track
VideoTrack The VideoTrack whose dimensions changed
- Inherited From:
-
trackDisabled
-
Parameters:
Name Type Description track
Track The Track that was disabled
- Inherited From:
-
trackEnabled
-
Parameters:
Name Type Description track
Track The Track that was enabled
- Inherited From:
-
trackRemoved
-
Parameters:
Name Type Description track
Track The Track that was removed
- Inherited From:
-
trackStarted
-
Parameters:
Name Type Description track
Track The Track that was started
- Inherited From: