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

    True if the audio is playing, false otherwise.

  • 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(): PannerOptions
  • Gets the 3D audio options if HRTF panning is used.

    Returns PannerOptions

    The current 3D audio options.

    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.

    Parameters

    • options: Partial<PannerOptions>

      The 3D audio options to set.

    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

    The current volume.

    Throws

    Throws an error if the sound has been cleaned up.

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

    Parameters

    • v: number

      The volume to set.

    Returns void

    Throws

    Throws an error if the sound has been cleaned up.

Methods

  • Parameters

    • connection: any

    Returns any

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

    Returns 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

    Parameters

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

    Returns void

  • Register event listener.

    Type Parameters

    Parameters

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

    Returns (() => void)

    Cleanup function

      • (): void
      • Returns void