goodatlas / react-native-audio-record

Audio record buffers for React Native (iOS and Android)
MIT License
176 stars 101 forks source link

startRecording() called on an uninitialized AudioRecord [Android] #61

Open mustafaskyer opened 3 years ago

mustafaskyer commented 3 years ago

this issue generated only on android, only at the first time, any suggestions about how to avoid this issue

code example below

      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: 'chat_voice_record.wav' // default 'audio.wav'
    };

      AudioRecord.init(options);

     async function startRecording() {
            const res = await checkMicrophonePermissions(); // check microphone permissions 
            if(!res.ok) return; // check permissions granted
            AudioRecord.start();
     }
maxckelly commented 3 years ago

hey @mustafaskyer did you find a solution to this?

vendeza commented 2 years ago

Need to get RECORD_AUDIO permission before calling AudioRecord.init()

charbelmansour005 commented 2 years ago

Need to get RECORD_AUDIO permission before calling AudioRecord.init()

already did post permission in AndroidManifest.xml

fukemy commented 1 year ago

any solution now? I have same problem

Sheharyar566 commented 1 year ago

I was getting the same issue because AudioRecord.init was being called before the permissions were being requested. I moved the init below permissions request and it worked.

RayanAbid commented 1 year ago

@Sheharyar566 did you ask for the permission in react native like this?

export const checkMicrophone = async () => {
  const result = await PermissionsAndroid.check(
    PermissionsAndroid.PERMISSIONS.RECORD_AUDIO
  );
  return result;
};

if not what did you use? Can you share that

Thanks