React Native iOS端WebRTC默认使用内置麦克风而非蓝牙麦克风的解决求助
React Native iOS端WebRTC默认使用内置麦克风而非蓝牙麦克风的解决求助
我在自己的React Native项目里同时集成了react-native-incall-manager和react-native-webrtc,本来是想让音频能路由到蓝牙麦克风的——Android那边测试完全没问题,但iOS端死活就是用手机内置麦克风,连不上我已经配对好的蓝牙设备。
我不死心,自己写了个原生模块来手动配置AVAudioSession,代码如下:
#import "AudioSessionManager.h" #import <AVFoundation/AVFoundation.h> @implementation AudioSessionManager RCT_EXPORT_MODULE(); RCT_EXPORT_METHOD(configureAudioSession:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { @try { AVAudioSession *session = [AVAudioSession sharedInstance]; // Set category [session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker error:nil]; // Set mode [session setMode:AVAudioSessionModeVoiceChat error:nil]; // Activate session [session setActive:YES error:nil]; resolve(@(YES)); } @catch (NSException *exception) { reject(@"session_config_error", @"Failed to configure AVAudioSession", nil); } } @end
结果运行之后还是没效果,iOS还是默认切回内置麦克风。有没有碰到过相同问题的老哥,或者懂iOS音频配置的大佬给指条路?
内容来源于stack exchange
相关产品推荐
相关产品推荐

