我正在使用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