Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

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

Open
mustafaskyer opened this issue Jul 6, 2021 · 6 comments
Open

Comments

@mustafaskyer
Copy link

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
Copy link

hey @mustafaskyer did you find a solution to this?

@vendeza
Copy link

vendeza commented Feb 2, 2022

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

@charbelmansour005
Copy link

charbelmansour005 commented Jul 25, 2022

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

already did post permission in AndroidManifest.xml

@fukemy
Copy link

fukemy commented Dec 1, 2022

any solution now? I have same problem

@Sheharyar566
Copy link

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
Copy link

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants