UNPKG

ez-web-audio

Version:

Making the Web Audio API super EZ since 2024.

55 lines 1.96 kB
import { Playable } from '../interfaces/playable'; import { Track } from '../track'; /** * A type representing either a single item or a nested array of items. * Used for flexible input to collection utilities. */ type NestedArray<T> = (T | T[])[]; /** * Stops all playable sounds in the provided array. * Supports nested arrays which are recursively flattened. * Uses best-effort error handling - attempts to stop all sounds even if some fail. * * @param sounds - Array of Playable instances or nested arrays of Playables * @throws CollectionError if any sounds fail to stop * * @example * ```typescript * const sounds = [sound1, sound2, [sound3, sound4]] * await stopAll(sounds) * ``` */ export declare function stopAll(sounds: NestedArray<Playable>): Promise<void>; /** * Pauses all tracks in the provided array. * Supports nested arrays which are recursively flattened. * Skips items that don't have a pause method (only Track has pause). * Uses best-effort error handling - attempts to pause all tracks even if some fail. * * @param tracks - Array of Track instances or nested arrays of Tracks * @throws CollectionError if any tracks fail to pause * * @example * ```typescript * const tracks = [track1, track2, [track3, track4]] * await pauseAll(tracks) * ``` */ export declare function pauseAll(tracks: NestedArray<Track>): Promise<void>; /** * Plays all playable sounds in the provided array. * Supports nested arrays which are recursively flattened. * Uses best-effort error handling - attempts to play all sounds even if some fail. * * @param sounds - Array of Playable instances or nested arrays of Playables * @throws CollectionError if any sounds fail to play * * @example * ```typescript * const sounds = [sound1, sound2, [sound3, sound4]] * await playAll(sounds) * ``` */ export declare function playAll(sounds: NestedArray<Playable>): Promise<void>; export {}; //# sourceMappingURL=collections.d.ts.map