我試圖用DIYCam錄製視頻,並將藍牙耳機的音頻路由設置爲音頻輸入,但似乎路由不起作用。據我所知,我只需要將音頻輸入路由到我的藍牙耳機,而且我不需要更改任何有關DIYCam的內容,對吧?這裏是我的代碼:iOS - 如何使用藍牙耳機錄製視頻作爲音頻輸入?
當視圖加載我創建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
);
}
而這些是啓動和回採的IBActions :
- (IBAction)startRecording:(id)sender
{
[self.camera startSession];
[self.camera captureVideoStart];
}
- (IBAction)stopRecording:(id)sender
{
[self.camera captureVideoStop];
[self.camera stopSession];
}