Class: RemoteAudioTrack

RemoteAudioTrack

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


Properties:
Name Type Argument Description
isEnabled boolean

Whether the RemoteAudioTrack is enabled

isSwitchedOff boolean

Whether the RemoteAudioTrack is switched off

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".

Parameters:
Name Type Description
track RemoteAudioTrack

The RemoteAudioTrack that was disabled

Overrides:

enabled

The RemoteAudioTrack was enabled, i.e. "unmuted".

Parameters:
Name Type Description
track RemoteAudioTrack

The RemoteAudioTrack that was enabled

Overrides:

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.

Parameters:
Name Type Description
track RemoteAudioTrack

The RemoteAudioTrack that was switched off


switchedOn

A RemoteAudioTrack was switched on.

Parameters:
Name Type Description
track RemoteAudioTrack

The RemoteAudioTrack that was switched on