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

How to record with headphone mic #364

Open
345ml opened this issue Mar 23, 2020 · 1 comment
Open

How to record with headphone mic #364

345ml opened this issue Mar 23, 2020 · 1 comment

Comments

@345ml
Copy link

345ml commented Mar 23, 2020

Tell us which versions you are using ( you can see the versions in your package.json ):

"react-native-audio": "^4.3.0",
"react-native-sound": "^0.11.0",
"react-native": "0.61.5",
"react": "16.9.0",

Expected behaviour :

For example, when you have an earphone mic on AirPods, you want to record audio from the headphone mic.

Actual behaviour

Even if wearing a headphone microphone, it seems to be recording audio from the device's microphone.

Steps to reproduce

Here's the code as I recorded it.

AudioRecorder.prepareRecordingAtPath(`${AudioUtils.DocumentDirectoryPath}/audio.aac`, {
  SampleRate: 16000,
  Channels: 1,
  AudioQuality: 'High',
  AudioEncoding: 'aac',
});
@345ml 345ml changed the title How to record with head mic How to record with headphone mic Mar 23, 2020
@345ml
Copy link
Author

345ml commented Mar 24, 2020

https://github.com/jsierles/react-native-audio/blob/f223414c6a965d24cea74179194613cf37e566ef/ios/AudioRecorderManager.m

I confirmed the code that works.

Around line 220.
Before

[_recordSession setCategory:AVAudioSessionCategoryMultiRoute error:nil];

After

[_recordSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
[_recordSession setMode:AVAudioSessionModeDefault error:nil];

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

1 participant