Skip to content
Class

MediaStreamAudioTrackSource

Audio source that encodes the data of a MediaStreamAudioTrack and pipes it into the output. This is useful for capturing live or real-time audio such as microphones or audio from other media elements. Audio will automatically start being captured once the connected Output is started, and will keep being captured until the Output is finalized or this source is closed.

Extends: AudioSource

Constructor

ts
constructor(
	track: MediaStreamAudioTrack,
	encodingConfig: AudioEncodingConfig,
): MediaStreamAudioTrackSource;

Creates a new MediaStreamAudioTrackSource from a MediaStreamAudioTrack, which will pull audio samples from the stream in real time and encode them according to AudioEncodingConfig.

Properties

errorPromise

ts
get errorPromise(): Promise<void>;

A promise that rejects upon any error within this source. This promise never resolves.

paused

ts
get paused(): boolean;

Whether this source is currently paused as a result of calling .pause().

Methods

pause()

ts
pause(): void;

Pauses the capture of audio data - any audio data emitted by the underlying media stream will be ignored while paused. This does not close the underlying MediaStreamAudioTrack, it just ignores its output.

resume()

ts
resume(): void;

Resumes the capture of audio data after being paused.

Released under the Mozilla Public License 2.0.