0.2.3 • Published 3 years ago
react-native-screen-audio-recorder v0.2.3
react-native-screen-audio-recorder
React Native library to record audio played by device
Record audio played by the device is available starting on Android 10 (Q = 29). For older Android versions the library will record microphone audio.
Installation
npm install react-native-screen-audio-recorder
Usage
import ScreenAudioRecorder, { Options } from 'react-native-screen-audio-recorder';
const options: Options = {
sampleRate: 16000,
channels: 1,
bitsPerSample: 16,
fileName: 'novo.wav',
fromMic: false,
saveFile: false,
audioEmitInterval: 1000
};
ScreenAudioRecorder.init(options);
ScreenAudioRecorder.start();
ScreenAudioRecorder.on('data', data => {
// real time base64-encoded audio
});
const audioFile = await AudioRecord.stop();
A full code example can be found at https://github.com/Nilsantos/react-native-screen-audio-recorder/blob/master/example/src/App.tsx
Options
Name | Description | Default |
---|---|---|
sampleRate | Sample Rate in hz. | 44100 |
channels | Channels, 1 = MONO, 2 = STEREO. | 1 |
bitsPerSample | Bits per sample. | 16 |
audioEmitInterval | Interval in miliseconds to receive audio base64 data to "on" event. | 0 |
fileName | Output file name. (Don't forget ".wav") | audio.wav |
fromMic | Record audio from microphone instead of device. For android before 10 even if the option is true, the audio will be captured from the microphone, because android doesn't support. | false |
saveFile | The captured audio must be recorded. | false |
Contributors
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Credits/References
The code was developed based on the library react-native-audio-record