ez-web-audio
Version:
Making the Web Audio API super EZ since 2024.
63 lines • 1.83 kB
TypeScript
import { TimeObject } from './utils/create-time-object';
import { Sound } from './sound';
/**
* A class that represents a "track" of music, similar in concept to a track on
* a CD or an MP3 player. Provides methods for tracking the play position of the
* underlying {{#crossLink "AudioBuffer"}}{{/crossLink}}, and pausing/resuming.
*
* @public
* @class Track
* @extends Sound
* @todo move play override to _play so that all super.play methods work
*/
export declare class Track extends Sound {
/**
* @property position Value is an object containing the current play position
* of the audioBuffer in three formats. The three
* formats are `raw`, `string`, and `pojo`.
*
* Play position of 6 minutes would be output as:
*
* {
* raw: 360, // seconds
* string: '06:00',
* pojo: {
* minutes: 6,
* seconds: 0
* }
* }
*/
get position(): TimeObject;
/**
* @property percentPlayed
* Value is the current play position of the
* audioBuffer, formatted as a percentage.
*/
get percentPlayed(): number;
/**
* @method play
* Plays the audio source immediately.
*/
play(): void;
/**
* @method pause
* Pauses the audio source by stopping without
* setting startOffset back to 0.
*/
pause(): void;
/**
* @method stop
* Stops the audio source and sets
* startOffset to 0.
*/
stop(): void;
/**
* @method _trackPlayPosition
* Sets up a `requestAnimationFrame` based loop that updates the
* startOffset as `audioContext.currentTime` grows.
* Loop ends when `_isPlaying` is false.
*/
private _trackPlayPosition;
}
export default Track;
//# sourceMappingURL=track.d.ts.map