npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-audio-record-plus

v1.0.0

Published

Audio record buffers for React Native with AVAudioSession category support

Readme

react-native-audio-record-plus

Audio record buffers for iOS and Android with AVAudioSession category support.

This is an enhanced version of react-native-audio-record with additional features for iOS AVAudioSession category control.

Features

  • ✅ Record audio on iOS and Android
  • ✅ Get audio data chunks in base64 format
  • ✅ Save recordings as WAV files
  • NEW: Control iOS AVAudioSession category (record / playAndRecord)

Install

npm install react-native-audio-record-plus
# or
yarn add react-native-audio-record-plus

For React Native >= 0.60, the library will be automatically linked.

For React Native < 0.60:

react-native link react-native-audio-record-plus

Usage

Basic Usage

import AudioRecord from 'react-native-audio-record-plus';

const options = {
  sampleRate: 16000,  // default 44100
  channels: 1,        // 1 or 2, default 1
  bitsPerSample: 16,  // 8 or 16, default 16
  audioSource: 6,     // android only (see below)
  wavFile: 'test.wav' // default 'audio.wav'
};

AudioRecord.init(options);

// Start recording with default category (record)
AudioRecord.start();

// Stop recording
AudioRecord.stop();
// or to get the wav file path
const audioFile = await AudioRecord.stop();

// Listen to audio data chunks
AudioRecord.on('data', data => {
  // base64-encoded audio data chunks
});

Advanced Usage - Control AVAudioSession Category (iOS)

import AudioRecord from 'react-native-audio-record-plus';

AudioRecord.init(options);

// Start with AVAudioSessionCategoryRecord (default)
// Use this for recording only
AudioRecord.start({ category: 'record' });

// Start with AVAudioSessionCategoryPlayAndRecord
// Use this when you need to play audio while recording (e.g., VoIP calls)
AudioRecord.start({ category: 'playAndRecord' });

// Or use default settings
AudioRecord.start();

AVAudioSession Categories

| Category | Description | Use Case | |----------|-------------|----------| | record | Recording only (default) | Standard audio recording | | playAndRecord | Simultaneous recording and playback | VoIP calls, voice chat, live audio processing |

Note: The category option only affects iOS. Android does not have an equivalent concept.

API Reference

AudioRecord.init(options)

Initialize the audio recorder with options.

Options:

  • sampleRate (number): Sample rate in Hz. Default: 44100
  • channels (number): Number of channels (1 or 2). Default: 1
  • bitsPerSample (number): Bits per sample (8 or 16). Default: 16
  • audioSource (number, Android only): Audio source constant. Default: 6 (VOICE_RECOGNITION)
  • wavFile (string): Output WAV file name. Default: 'audio.wav'

AudioRecord.start(options?)

Start recording.

Options:

  • category (string, iOS only): AVAudioSession category ('record' or 'playAndRecord'). Default: 'record'

AudioRecord.stop()

Stop recording and return the WAV file path.

Returns: Promise<string> - Path to the recorded WAV file

AudioRecord.on(event, callback)

Listen to recording events.

Events:

  • data: Emitted when audio data is available. Callback receives base64-encoded audio data.

Platform-Specific Notes

Android

For audioSource, use one of the constant values from MediaRecorder.AudioSource. Default value is 6 (VOICE_RECOGNITION).

iOS

The library uses AVAudioSession for managing audio sessions. You can now control the session category when starting recording:

  • AVAudioSessionCategoryRecord: For recording only
  • AVAudioSessionCategoryPlayAndRecord: For simultaneous recording and playback

Permissions

Don't forget to add microphone permissions in your app.

iOS (ios/YourApp/Info.plist)

<key>NSMicrophoneUsageDescription</key>
<string>This app requires access to the microphone for audio recording.</string>

Android (android/app/src/main/AndroidManifest.xml)

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Decoding Audio Data

Use a 3rd-party module like buffer to decode base64 data.

// yarn add buffer
import { Buffer } from 'buffer';

AudioRecord.on('data', data => {
  const chunk = Buffer.from(data, 'base64');
  // Process audio chunk
});

License

MIT