audio-utilis
v1.1.0
Published
can record,play,stop and cleanup
Downloads
8
Readme
audio-utilis
can record,play,stop and cleanup
Installation
npm install audio-utilis
Usage
import { StartRecording, StopRecording, PlayRecordedFile, CleanUpFiles, PauseRecordedFile, ResumeRecordedFile, StopWhilePlayingRecordedFile, GetRecordingObj, } from 'audio-utilis';
// ...
const [isRecording, setIsRecording] = useState(false); const [isPlaying, setIsPlaying] = useState(false);
const handleStartRecs = () => { setIsRecording(true); StartRecording(); };
const handleStopRecs = () => { ... setIsRecording(false); StopRecording(); };
const cleanUpRecds = () => { ... CleanUpFiles(); };
const handlePlayAudio = async () => { return new Promise((resolve, reject) => { setIsPlaying(true); PlayRecordedFile() .then(flag => { console.log('in func ===> ', flag); setIsPlaying(!flag); resolve(flag); }) .catch(error => { reject(error); setIsPlaying(false); }); }); };
const handlePauseRecd = () => { setIsPlaying(false); PauseRecordedFile(); };
const getFile = () => { const recdFile = await GetRecordingObj(); console.log(recdFile); };
const cancelAudioPlayer = () => { StopWhilePlayingRecordedFile(); setIsPlaying(false) };
const resumeRecording = () => { ResumeRecordedFile(); setIsRecording(True) };