我正在尝试使用DIYCam录制视频并将蓝牙耳机的音频路由设置为音频输入,但似乎路由不起作用。据我了解,我只需要将音频输入路由到我的蓝牙耳机,我不需要对 DIYCam 进行任何更改,对吗?这是我的代码:
当视图加载时,我创建了 DIYCam 实例:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.navigationController setNavigationBarHidden:YES];
self.camera = [[DIYCam alloc] initWithFrame:self.view.bounds];
self.camera.delegate = self;
[self.camera setupWithOptions:nil]; // Check DIYAV.h for options
[self.camera setCamMode:DIYAVModeVideo];
[self.view addSubview:self.camera];
[self.view sendSubviewToBack:self.camera];
if( self.bluetoothInput ) {
[self setBluetoothAudioInput];
}
}
这是我的蓝牙路由功能:
- (void)setBluetoothAudioInput
{
// create and set up the audio session
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setDelegate:self];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];
[audioSession setActive:YES error:nil];
// set up for bluetooth microphone input
UInt32 allowBluetoothInput = 1;
OSStatus stat = AudioSessionSetProperty (
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
sizeof (allowBluetoothInput),
&allowBluetoothInput
);
}
这些是用于启动和停止的 IBAction:
- (IBAction)startRecording:(id)sender
{
[self.camera startSession];
[self.camera captureVideoStart];
}
- (IBAction)stopRecording:(id)sender
{
[self.camera captureVideoStop];
[self.camera stopSession];
}