Skip to content

React Native audio recording module used for DSP with Android + iOS

License

Notifications You must be signed in to change notification settings

qiuxiang/react-native-recording

Repository files navigation

react-native-recording npm version

React Native audio recording module used for DSP with Android + iOS

Install

$ npm i react-native-recording

Usage

import { PermissionsAndroid } from "react-native";
import Recording from "react-native-recording";

await PermissionsAndroid.requestMultiple([
  PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
]);

Recording.init({
  bufferSize: 4096,
  sampleRate: 44100,
  bitsPerChannel: 16,
  channelsPerFrame: 1,
});

const listener = Recording.addRecordingEventListener((data) =>
  console.log(data)
);

Recording.start();

// stop recording
Recording.stop();
listener.remove();

Microphone request for iOS 10 and above

As of iOS 10.0, you must declare an intention to access a microphone. Add NSMicrophoneUsageDescription key and declaration value in Info.plist.

<dict>
    ...
	<key>NSMicrophoneUsageDescription</key>
	<string>This app uses the microphone to record the soundscape.</string>
    ...
</dict>