-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
startRecording() called on an uninitialized AudioRecord #10
Comments
Have you allowed microphone permission on your app? |
I got this error when using the android simulator. It's important to remember that the android simulator doesn't have a microphone (correct me if i'm wrong). Did you try debugging on an actual device? |
For android, I mainly test on real devices. |
I am getting this error on a specific device (my other two devices run the code just fine!). The device is a little older, looking to see if you have any insight on this. Device: ZTE Blade C321 Code:
|
Check the sample rate of your device. |
Is there a way to check if the recording object was set up successfully? The app being developed requires support for as many older devices as possible |
In Java, you could write a loop that tries to instantiate an AudioRecord object with different sample rates. public void getValidSampleRates() {
for (int rate : new int[] {8000, 11025, 16000, 22050, 44100}) { // add the rates you wish to check against
int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT, AudioFormat.ENCODING_PCM_16BIT);
if (bufferSize > 0) {
// buffer size is valid, Sample rate supported
}
}
} You could then add this functionality into a react-native package. For iOS, i'm not 100% sure, but I think all of the sample rates are the same. |
Trying the looping method. I've discovered that the device works when the sample rate is set to 22050. Here is my current code, which is not working:
What happens is that even though I try to start recording inside of a try block, I still get the red screen of death (ie it is not caught). What I need to do is one of two things:
Any help to achieve either is greatly appreciated. I could not find anything within the recording object to satisfy option 2 |
Update: Got this working with my code. I had to fork this repo and make some changes which applies the looping process as stated by @navrajkambo (thank you!), except instead of checking bufferSize being >0, I check the audiorecord state. Here is how I got it working:
Forked repo can be found here: |
I also tried to run the example from the library but got the error below:
I'm using an Android device with the Expo app for testing and I set microphone permission to be on for Expo. |
I'm unsure that you can use this library with Expo. You might want to look into that (I may be wrong). If you cannot, you must eject the app, or use a different library (expo has one built in) |
I am also facing same issue . I added permission in manifest file But still facing the issue. How to solve it? |
i got error when first trying to use this library based on example.
startRecording() called on an uninitialized AudioRecord
The text was updated successfully, but these errors were encountered: