Class: RemoteAudioTrack

RemoteAudioTrack

A RemoteAudioTrack represents an AudioTrack published to a Room by a RemoteParticipant.


Properties:
Name Type Argument Description
isEnabled boolean

Deprecated: Use (.switchOffReason !== "disabled-by-publisher") instead Whether the RemoteAudioTrack is enabled (Deprecated only for large group Rooms)

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 null; The RemoteAudioTrack is initially switched off with this property set to disabled-by-subscriber

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:
RangeError
Returns:
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

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:

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 to true and switchOffReason is set to a TrackSwitchOffReason in large group Rooms (switchOffReason is null non-large group Rooms). Also, the mediaStreamTrack property is set to null (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 to false and switchOffReason is set to null. Also, the mediaStreamTrack 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