Properties:
Name | Type | Argument | Description |
---|---|---|---|
isEnabled |
boolean |
|
|
isSwitchedOff |
boolean | Whether the RemoteAudioTrack is switched off |
|
switchOffReason |
TrackSwitchOffReason |
<nullable> |
The reason for the RemoteAudioTrack being switched off;
If switched on, it is set to |
sid |
Track.SID | The RemoteAudioTrack's SID |
|
priority |
Track.Priority |
<nullable> |
The subscribe priority of the RemoteAudioTrack |
Fires:
Extends
Methods
-
attach()
-
Create an HTMLAudioElement and attach the AudioTrack to it.
The HTMLAudioElement's
srcObject
will be set to a new MediaStream containing the AudioTrack's MediaStreamTrack.- Inherited From:
- Overrides:
Returns:
audioElement
- Type
- HTMLAudioElement
Example
const Video = require('twilio-video'); Video.createLocalAudioTrack().then(function(audioTrack) { const audioElement = audioTrack.attach(); document.body.appendChild(audioElement); });
-
detach()
-
Detach the AudioTrack from all previously attached HTMLMediaElements.
- Inherited From:
- Overrides:
Returns:
mediaElements
- Type
- Array.<HTMLMediaElement>
Example
const mediaElements = audioTrack.detach(); mediaElements.forEach(mediaElement => mediaElement.remove());
-
setPriority(priority)
-
Update the subscribe Track.Priority of the RemoteAudioTrack.
Parameters:
Name Type Argument Description priority
Track.Priority <nullable>
the new subscribe Track.Priority; Currently setPriority has no effect on audio tracks.
Throws:
RangeErrorReturns:
- Type
- this
Events
-
disabled
-
The RemoteAudioTrack was disabled, i.e. "muted" (Deprecated only for large group Rooms).
Parameters:
Name Type Description track
RemoteAudioTrack The RemoteAudioTrack that was disabled
- Overrides:
- Deprecated:
-
- Use
switchedOff
(.switchOffReason === "disabled-by-publisher"
) instead
- Use
-
enabled
-
The RemoteAudioTrack was enabled, i.e. "unmuted" (Deprecated only for large group Rooms).
Parameters:
Name Type Description track
RemoteAudioTrack The RemoteAudioTrack that was enabled
- Overrides:
- Deprecated:
-
- Use
switchedOn
instead
- Use
-
started
-
The RemoteAudioTrack started. This means there is enough audio data to begin playback.
Parameters:
Name Type Description track
RemoteAudioTrack The RemoteAudioTrack that started
- Overrides:
-
switchedOff
-
A RemoteAudioTrack was switched off. The media server stops sending media for the RemoteAudioTrack until it is switched back on. Just before the event is raised,
isSwitchedOff
is set totrue
andswitchOffReason
is set to a TrackSwitchOffReason in large group Rooms (switchOffReason
isnull
non-large group Rooms). Also, themediaStreamTrack
property is set tonull
(only in large group Rooms).Parameters:
Name Type Argument Description track
RemoteAudioTrack The RemoteAudioTrack that was switched off
switchOffReason
TrackSwitchOffReason <nullable>
The reason the RemoteAudioTrack was switched off
-
switchedOn
-
A RemoteAudioTrack was switched on. The media server starts sending media for the RemoteAudioTrack until it is switched off. Just before the event is raised,
isSwitchedOff
is set tofalse
andswitchOffReason
is set tonull
. Also, themediaStreamTrack
property is set to a MediaStreamTrack that is the source of the RemoteAudioTrack's media.Parameters:
Name Type Description track
RemoteAudioTrack The RemoteAudioTrack that was switched on