UNPKG

react-sound-html5

Version:

A tiny React component wich provide simple abstraption to manipulate HTML5 AudioContext API (Equalizer, visualisation, stereo, basic controls)

64 lines (63 loc) 1.61 kB
import React from 'react'; declare enum SoundStatus { PAUSED = "PAUSED", PLAYING = "PLAYING", STOPPED = "STOPPED" } declare type OnPlayingArgs = { position: number; duration: number; }; /** * Sound Props */ export interface ISoundProps { url: string; playStatus?: string; position?: number; /** volume */ volume?: number; onPlaying?: (args: OnPlayingArgs) => void; onFinishedPlaying?: (event: any) => void; onLoading?: (event: any) => void; onLoad?: (event: any) => void; onVisualizationChange?: (data: number[]) => void; equalizer?: Record<string, number>; preAmp?: number; stereoPan?: number; } /** * Sound Component */ export declare class Sound extends React.Component<ISoundProps> { private audio; private audioContext; private gainNode; private source; private filters; private analyser; private stereoPanner; private qValues; private frequencyData; private animationFrame; static status: typeof SoundStatus; constructor(props: ISoundProps); private attachRef; private createFilterNodes; private formatDataVizByFrequency; private handleVisualizationChange; private handleTimeUpdate; private setPlayerState; private shouldUpdatePosition; private shouldUpdateEqualizer; private setVolume; private setPosition; private setStereoPan; protected play(): void; protected pause(): void; protected stop(): void; componentDidUpdate(prevProps: ISoundProps): void; componentDidMount(): void; render(): JSX.Element; } export {};