Class: AudioTrack

AudioTrack

An AudioTrack is a Track representing audio.


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();
});
 

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:

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:

started

The Track started. This means that the Track contains enough audio or video to begin playback.

Parameters:
Name Type Description
track Track

The Track that started

Inherited From: