useAudio
useAudio provides play, pause, and stop functionality and provides
the name of the current audio, the playback state, and the audioBufferSource.
API
const {
data: { name, isPause, isPlaying, audioBufferSourceNode },
play,
stop,
pause,
} = useAudio(audioFile);
options
audioFile: string- Required
- mp3, wav file
name- mp3, wav file name(title)
isPause- This means whether the audio file is on pause.
- It becomes true when the pause function is executed.
- It is false when playing..
isPlaying- Means whether the audio file is playing.
- True if the play function is executed.
- True if playing.
audioBufferSourceNode- Means Web Audio API's audioBufferSourceNode.
- AudioBufferSourceNode MDN
play- Play the audio file.
- When this function is run,
isPausewill befalseandisPlayingwill betrue.
pause- Pause the audio file.
- When this function is run,
isPausewill betrueandisPlayingwill befalse.
stop- Stop the audio file.
- When this function is run,
isPause,isPlayingwill befalse,