react-native-webrtc / react-native-webrtc/react-native-incall-manager
Unable to change from speaker to bluetooth device instead it is routing audio to phone earpiece
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 597
- Forks
- 201
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 1
Description
As I am using setAudioRoute to set back to bluetooth and I am not able to switch
await InCallManager.setAudioRoute(‘’,'BLUETOOTH').then((response) => {
})
iOS Native function
RCT_EXPORT_METHOD(setAudioRoute: (NSString *)uuid
inputName:(NSString *)inputName
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
#ifdef DEBUG
NSLog(@"[RNCallKeep][setAudioRoutesetAudioRoute] - inputName: %@", inputName);
#endif
@try {
NSError* err = nil;
AVAudioSession* myAudioSession = [AVAudioSession sharedInstance];
if ([inputName isEqualToString:@"Speaker"]) {
BOOL isOverrided = [myAudioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];
if(!isOverrided){
[NSException raise:@"overrideOutputAudioPort failed" format:@"error: %@", err];
}
resolve(@"Speaker");
return;
}
NSArray *ports = [RNInCallManager getAudioInputs];
for (AVAudioSessionPortDescription *port in ports) {
if ([port.portName isEqualToString:inputName]) {
BOOL isSetted = [myAudioSession setPreferredInput:(AVAudioSessionPortDescription *)port error:&err];
if(!isSetted){
[NSException raise:@"setPreferredInput failed" format:@"error: %@", err];
}
resolve(inputName);
return;
}
}
}
@catch ( NSException *e ){
NSLog(@"[RNCallKeep][setAudioRoute] exception: %@",e);
reject(@"Failure to set audio route", e, nil);
}
}
What I tried:
- Setting the setAudioRoute directly
- Setting the route to bluetooth directly from avaudiosessionListener
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the iOS native setAudioRoute implementation shown in the issue and trace how getAudioInputs and AVAudioSession handle the Bluetooth route. Reproduce switching from speaker to Bluetooth, then verify that the selected Bluetooth input is retained instead of routing audio to the phone earpiece.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, objective-c, react-native
- Domain
- audio-video-rtc, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100