UNPKG

ts-audio

Version:

`ts-audio` is an agnostic and easy-to-use library to work with the `AudioContext` API and create Playlists.

39 lines (38 loc) 1.37 kB
import type { EventEmitter } from './EventEmitter'; type callbackType = <T>(param: { [data: string]: T; }) => void; /** * EventHandler class to manage event listeners for an audio context. */ export declare class EventHandler { private emitter; private audioCtx; /** * Creates an instance of EventHandler. * @param emitter - The event emitter instance to manage event listeners. * @param audioCtx - AudioContext instance to monitor state changes. Optional to facilitate testing. */ constructor(emitter: EventEmitter, audioCtx?: AudioContext); /** * Registers a callback for the 'decoded' event. * @param callback - The callback to be invoked when the event occurs. */ ready(callback: callbackType): void; /** * Registers a callback for the 'start' event. * @param callback - The callback to be invoked when the event occurs. */ start(callback: callbackType): void; /** * Registers a callback for the 'end' event. * @param callback - The callback to be invoked when the event occurs. */ end(callback: callbackType): void; /** * Monitors the state changes of the AudioContext and invokes the callback. * @param callback - The callback to be invoked when the AudioContext state changes. */ state(callback: callbackType): void; } export {};