Options
All
  • Public
  • Public/Protected
  • All
Menu

AudioPool

A MediaPool designed to handle playback of audio files. Uses Howler.js under the hood.

Hierarchy

Index

Constructors

constructor

  • new AudioPool(__namedParameters: object): AudioPool
  • Parameters

    • __namedParameters: object
      • assets: Asset[]
      • cleanEvery: number

        The number of iterations before AudioPool.cleanCache is automatically called.

      • dropCount: number | function
      • dropDistributionWeight: number | function
      • duration: number | function
      • loop: boolean
      • ordered: boolean

    Returns AudioPool

Properties

assets

assets: Asset[]

List of media sources used by this Pool.

destroy$

destroy$: Observable<void>

Fires when the Pool stops and is not looping.

drop$

drop$: Observable<number>

Fires for each drop in the Pool. Callback is passed the drop index.

dropCount

dropCount: number

The number of times the present run will drop.

dropDistributionWeight

dropDistributionWeight: number = 1

The distribution weighting for drops in the Pool * (1 = neutral, lower = later, higher = earlier). Uses weightedRandom under the hood.

NB: This will be changed to use a distribution function in future versions.

duration

duration: number

Total duration of the current iteration of the pool (ms).

loop

loop: boolean = false

Whether the Pool should restart when it ends.

ordered

ordered: boolean = false

Determines whether the Assets will be played in order or at random. (To weight the randomness, add duplicate Assets.)

pause$

pause$: Observable<void>

Fires when the Pool is paused.

play$

play$: Observable<HowlReference>

Fires when a sound begins to play. Use this instead of Pool.drop$ to gain access to the sound's HowlReference.

queue

queue: Asset[] = []

resume$

resume$: Observable<void>

Fires when the Pool is resumed.

start$

start$: Observable<void>

Fires at the start of a Pool cycle.

stop$

stop$: Observable<void>

Fires at the end of a Pool cycle.

Static HOWL_CACHE

HOWL_CACHE: Map<Asset, Howl> = new Map()

Cache of Howls across all instances of AudioPool. Optionally cleaned by setting cleanEvery the constructor (recommended) or manually calling AudioPool.cleanCache().

Static QUEUE

QUEUE: Map<Asset, number> = new Map()

List of sources that are enqueued for all extant AudioPools. Used to help cache maintenance.

Methods

pause

  • pause(): void
  • Pauses the Pool.

    Returns void

preloadAll

  • preloadAll(): Observable<void>
  • Preloads all Assets in the list. Returned observable fires when each sound's Howl fires its load event.

    Returns Observable<void>

resume

  • resume(): void
  • Resumes the Pool.

    Returns void

start

  • start(): void
  • Starts the pool.

    Returns void

stop

  • stop(): void

Static cleanCache

  • cleanCache(): void
  • Cleans the entire AudioPool.HOWL_CACHE by unloading Howls which aren't playing, aren't queued, and aren't loading. Automatically called if cleanEvery is set in AudioPool.constructor.

    Returns void

Static getHowl

  • getHowl(asset: Asset, onload?: function): Howl
  • Gets or makes a Howl for a src sound as needed. Use this to interface with the cache or to make new Howls.

    If a Howl doesn't exist for a source, getHowl makes one, adds it to the cache, and returns it.

    If a Howl does already exist, getHowl simply returns it.

    Parameters

    • asset: Asset
    • Optional onload: function
        • (): any
        • Returns any

    Returns Howl

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc