Class MediaStreamPlayback

Hierarchy

  • BasePlayback
    • MediaStreamPlayback

Constructors

Properties

_fadeTimeout?: Timeout
_filters: BiquadFilterNode[] = []
_isFading: boolean = false
_panType: PanType = "stereo"
_playing: boolean = false
eventEmitter: TypedEventEmitter<PlaybackEvents> = ...
gainNode?: GainNode
hasStarted: boolean = false
primeElement?: HTMLAudioElement

Muted media element that keeps Chromium's decode pipeline alive for the stream so the Web Audio tap receives real audio. See MediaStreamSoundOptions.primeWithMediaElement.

stopTracksOnStop: boolean

Accessors

  • get isFading(): boolean
  • Whether a fade is currently in progress.

    Returns boolean

  • get isPlaying(): boolean
  • Checks if the audio is currently playing.

    Returns boolean

  • get position(): Position
  • Gets the position of the audio source in 3D space (HRTF panning only).

    Returns Position

    The [x, y, z] coordinates of the audio source.

    Throws

    Throws an error if the sound has been cleaned up or if HRTF panning is not used.

  • set position(position): void
  • Sets the position of the audio source in 3D space (HRTF panning only).

    Parameters

    • position: Position

      The [x, y, z] coordinates of the audio source.

    Returns void

    Throws

    Throws an error if the sound has been cleaned up or if HRTF panning is not used.

  • get stereoPan(): null | number
  • Gets the stereo panning value.

    Returns null | number

    The current stereo pan value, or null if stereo panning is not applicable.

  • set stereoPan(value): void
  • Sets the stereo panning value.

    Parameters

    • value: number

      The stereo pan value to set, between -1 (left) and 1 (right).

    Returns void

    Throws

    Throws an error if stereo panning is not available, if the sound has been cleaned up, or if the value is out of bounds.

  • get threeDOptions(): ThreeDOptions
  • Gets the 3D audio options if HRTF panning is used.

    Returns ThreeDOptions

    The current 3D audio options (HRTF variant).

    Throws

    Throws an error if the sound has been cleaned up or if HRTF panning is not used.

  • set threeDOptions(options): void
  • Sets the 3D audio options for HRTF panning. Accepts either a full ThreeDOptions value or a partial HRTF override. Any field omitted from the input is left at its current value on the underlying PannerNode.

    Parameters

    Returns void

    Throws

    Throws an error if the sound has been cleaned up or if HRTF panning is not used.

  • get volume(): number
  • Gets the current volume of the audio.

    Returns number

    Throws

    Throws an error if the sound has been cleaned up.

  • set volume(v): void
  • Sets the volume of the audio.

    Parameters

    • v: number

    Returns void

    Throws

    Throws an error if the sound has been cleaned up.

Methods

  • Cancels any in-progress fade, emitting fadeCancel if a fade was active.

    Returns void

  • Type Parameters

    • K extends (keyof BaseAudioEvents) | "seek"

    Parameters

    Returns void

  • Type Parameters

    • K extends (keyof BaseAudioEvents) | "seek"

    Parameters

    Returns Promise<void>

  • Fades in from silence to the current volume.

    Parameters

    • duration: number

      The fade duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when the fade completes.

  • Fades out from the current volume to silence.

    Parameters

    • duration: number

      The fade duration in milliseconds.

    • Optional type: FadeType

      The fade curve type. Defaults to "linear".

    Returns Promise<void>

    Resolves when the fade completes.

  • Fades the volume to a target value, emitting fadeStart and fadeEnd events.

    Parameters

    • value: number
    • duration: number
    • type: FadeType = "linear"

    Returns Promise<void>

  • Remove event listener.

    Type Parameters

    • K extends (keyof BaseAudioEvents) | "seek"

    Parameters

    • event: K
    • listener: ((data) => void)

    Returns void

  • Register event listener.

    Type Parameters

    • K extends (keyof BaseAudioEvents) | "seek"

    Parameters

    • event: K
    • listener: ((data) => void)

    Returns (() => void)

    Cleanup function

      • (): void
      • Returns void