我正在使用AVCaptureSession製作適用於iOS 5.0的電影應用程序。我給用戶的能力,開始暫停 - 開始 - 停止錄製動畫AVCaptureSession暫停和繼續錄製
我已經定義了三個按鈕是
開始錄製
停止錄製
暫停錄製
我能夠成功開始&停止錄音。我無法做的是暫停錄製,然後再重新開始。我看着堆棧溢出的這個問題/答案,但我不知道他們如何暫停和恢復視頻?我在這裏找到了一些其他的帖子,但是他們沒有任何代碼可以用來試用。如果AVAssetWrtier是如何使用AVCaptureSession的方法?
Pause & resume video capture for same file with AVFoundation in iOS
這裏是我的三個按鈕
-(IBAction) makeMovieNow
{
NSLog(@"makeMovieNow ...");
[session startRunning];
[movieFileOutput startRecordingToOutputFileURL:movieURL recordingDelegate:self];
}
-(IBAction) makeMovieStop
{
NSLog(@"makeMovieStop ...");
//stop recording
[session stopRunning];
}
-(IBAction) makeMoviePause
{
NSLog(@"makeMoviePause ...");
//pause video??? How?
}
//********** DID FINISH RECORDING TO OUTPUT FILE AT URL **********
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
NSLog(@"didFinishRecordingToOutputFileAtURL - enter");
BOOL RecordedSuccessfully = YES;
if ([error code] != noErr)
{
NSLog(@"ERROR RECODING MOVIE!!! - enter");
// A problem occurred: Find out if the recording was successful.
id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey];
if (value)
{
RecordedSuccessfully = [value boolValue];
}
}
if (RecordedSuccessfully)
{
//----- RECORDED SUCESSFULLY -----
NSLog(@"didFinishRecordingToOutputFileAtURL - success");
UISaveVideoAtPathToSavedPhotosAlbum(videoPath2, self, nil, nil);
}
}
我發現它絕對迷人的是暫停錄音選項在MAC的API http://developer.apple.com/library/mac/#documentation/QuickTime/Reference/QTCaptureFileOutput_Ref/Introduction/Introduction.html – 2013-02-26 23:22:12