new Twilio.Video.LocalAudioTrack(mediaStreamTrack, options)
Construct a LocalAudioTrack from a MediaStreamTrack.
Parameters:
Name | Type | Description |
---|---|---|
mediaStreamTrack |
MediaStreamTrack | The underlying MediaStreamTrack |
options |
LocalTrackOptions | LocalTrack options |
Extends
Methods
-
attach()
-
Attach the Track to a newly created HTMLMediaElement.
The HTMLMediaElement's
srcObject
will be set to a new MediaStream containing the Track's MediaStreamTrack.- Inherited From:
- Overrides:
Returns:
Either an HTMLAudioElement or HTMLVideoElement, depending on the Track's kind
- Type
- HTMLMediaElement
Example
var Video = require('twilio-video'); Video.createLocalVideoTrack().then(function(track) { var videoElement = track.attach(); document.getElementById('my-container').appendChild(videoElement); });
-
detach()
-
Detach a Track from all previously attached HTMLMediaElements.
- Inherited From:
- Overrides:
Returns:
The detachedHTMLMediaElements
- Type
- Array.<HTMLMediaElement>
Example
var detachedElements = track.detach(); detachedElements.forEach(function(el) { el.remove(); });
-
disable()
-
Disable the LocalAudioTrack. This is effectively "mute".
- Overrides:
Fires:
Returns:
- Type
- this
-
enable( [enabled])
-
Enable or disable the LocalAudioTrack. This is effectively "unmute" or "mute".
Parameters:
Name Type Argument Description enabled
boolean <optional>
Specify false to mute the LocalAudioTrack
- Overrides:
Fires:
Returns:
- Type
- this
-
enable()
-
Enable the LocalAudioTrack. This is effectively "unmute".
- Overrides:
Fires:
Returns:
- Type
- this
-
stop()
-
Calls stop on the underlying MediaStreamTrack. If you choose to stop a LocalTrack, you should use LocalParticipant#removeTrack to remove it after stopping. You do not need to stop a track before using LocalTrack#disable or LocalParticipant#removeTrack.
- Inherited From:
- Overrides:
Returns:
- Type
- this
Events
-
disabled
-
The Track was disabled. For AudioTracks this means "muted", and for VideoTracks this means "paused".
Parameters:
Name Type Description track
Track The Track that was disabled
- Inherited From:
- Overrides:
-
enabled
-
The Track was enabled. For AudioTracks this means "unmuted", and for VideoTracks this means "unpaused".
Parameters:
Name Type Description track
Track The Track that was enabled
- Inherited From:
- Overrides:
-
started
-
Parameters:
Name Type Description track
Track The Track that started
- Inherited From:
- Overrides:
-
stopped
-
The LocalTrack was stopped, either because LocalTrack#stop was called or because the underlying MediaStreamTrack ended).
Parameters:
Name Type Description track
LocalTrack The LocalTrack that stopped
- Inherited From: