xiqi / react-native-live-audio-stream

Get live audio stream data for React Native (works for iOS and Android)
MIT License
71 stars 29 forks source link

[Android ]Ask for permission to record before initialize #12

Open Merwan1010 opened 2 years ago

Merwan1010 commented 2 years ago

If you encounter the following error when starting the record :

startRecording() called on an uninitialized AudioRecord

Please make sure to wait for the permission to record before initialize.

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

  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)
    bufferSize: 4096 * 2 // default is 2048
  }

  LiveAudioStream.init(options);

Would it be possible to edit the readme.md ?