0.2.3 • Published 3 years ago

react-native-screen-audio-recorder v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

NameDescriptionDefault
sampleRateSample Rate in hz.44100
channelsChannels, 1 = MONO, 2 = STEREO.1
bitsPerSampleBits per sample.16
audioEmitIntervalInterval in miliseconds to receive audio base64 data to "on" event.0
fileNameOutput file name. (Don't forget ".wav")audio.wav
fromMicRecord 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
saveFileThe 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