2013-07-17 185 views
0

我正在開發一款iPhone應用程序,其中需要從iPhone前置攝像頭錄製視頻並同時播放其中的音頻文件。我使用AVCamCaptureManager錄製視頻。 我記錄在後臺使用dispatch_queue如下視頻:同時錄製視頻和播放音頻文件

// ------ This will start recording in Background -------- 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ 
    [self startRecordingInBackground]; 
}); 

,直到一些播放音頻文件時,它工作正常。

// ----- Playing Audio File --------- 
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Start_b4_counting_down" ofType:@"mp3" inDirectory:Nil]; 
    NSLog(@"filePath %@", filePath); 
    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: filePath]; 
    self.theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:NULL]; 
    self.theAudio.volume = 10.0; 
    self.theAudio.delegate = self; 
    [self.theAudio prepareToPlay]; 
    [self.theAudio play]; 

一旦音頻文件播放的視頻錄製停止,不會恢復。

回答

1

我對這個主題沒有想法,但也許this answer會對你有所幫助。 祝你好運!

+0

謝謝@Berkin你的鏈接幫了我很多..! – Mahesh

+0

不客氣,很高興聽到這:) –