duckengine
Version:
A 2D Game Engine for the web.
114 lines (113 loc) • 2.82 kB
TypeScript
import { Duck } from '../../index';
/**
* @class SoundPlayer
* @classdesc Creates a SoundPlayer class.
* @description The SoundPlayer Class. Plays audio
* @since 1.0.0-beta
*/
export default class SoundPlayer {
path: string;
element: HTMLAudioElement;
protected sprites: Duck.Types.Sound.Sprite[];
/**
* @constructor SoundPlayer
* @description Creates a SoundPlayer instance
* @param {string} path Path to sound file
* @param {Duck.Types.Sound.Config} [options] Sound Configuration
* @since 1.0.0-beta
*/
constructor(path: string, options?: Duck.Types.Sound.Config);
/**
* @memberof Sound
* @description Plays the audio
* @since 1.0.0-beta
*/
play(): void;
/**
* @memberof Sound
* @description Pauses the audio
* @since 1.0.0-beta
*/
pause(): void;
/**
* @memberof Sound
* @description Mutes the audio
* @since 1.1.0
*/
mute(): void;
/**
* @memberof Sound
* @description Unmutes the audio
* @since 1.1.0
*/
unmute(): void;
/**
* @memberof Sound
* @description Pauses the audio, alias to SoundPlayer.pause
* @since 2.1.0
*/
stop(): void;
/**
* @memberof Sound
* @description Sets the loop of the audio
* @since 2.1.0
*/
loop(loop?: boolean): void;
/**
* @memberof Sound
* @description Seeks the audio
* @param {number} timeInSeconds Time in seconds to seek to
* @since 1.0.0-beta
*/
seek(timeInSeconds: number): void;
/**
* @memberof Sound
* @description Restarts the audio
* @since 1.0.0-beta
*/
restart(): void;
/**
* @memberof Sound
* @description Sets the volume of the audio
* @since 1.0.0-beta
*/
setVolume(volume: number): void;
/**
* @memberof Sound
* @description Gets the duration of the sound
* @since 1.0.0-beta
*/
get duration(): number;
/**
* @memberof Sound
* @description Gets the playing state of the sound
* @since 1.0.0-beta
*/
get isPlaying(): boolean;
/**
* @memberof Sound
* @description Gets the volume of the sound
* @since 1.0.0-beta
*/
get volume(): number;
/**
* @memberof Sound
* @description Gets the mute state of the sound
* @since 1.0.0-beta
*/
get isMuted(): boolean;
/**
* @memberof Sound
* @description Plays a sound sprite based on the key
* @param {string} key Key of the sound sprite
* @since 1.0.0-beta
*/
playSprite(key: string): void;
/**
* @memberof Sound
* @description Sets the audio src/path
* @param {string} path Audio src/path
* @since 1.0.0-beta
*/
setPath(path: string): void;
}