2013-05-29 186 views
0

我試圖用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]; 
} 

回答

0

我相信你需要讓用戶手動設置使用什麼輸入設備f或音頻。我只是有一個類似的問題,並使用一個MPVolumeView與showsVolumeSlider布爾值設置爲NO。這提供了一個可點擊的按鈕來從可用的列表中設置所需的輸入。

退房: AudioSession input from bluetooth output to line out or speaker

0

試試這個:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];