我正在使用 AVCaptureSession 为 iOS 5.0 制作电影应用程序。我让用户能够开始-暂停-开始-停止录制电影
我定义的三个按钮是
开始录制
停止录制
暂停录音
我能够成功开始和停止录制。我无法做的是暂停录音,然后再次恢复。我看了这个关于堆栈溢出的问题/答案,但我不知道他们是如何暂停和恢复视频的?我确实在这里找到了其他一些帖子,但没有一个有任何示例代码可供我试用。如果 AVAssetWrtier 是要走的路,你如何将它与 AVCaptureSession 一起使用?
在 iOS 中使用 AVFoundation 暂停和恢复相同文件的视频捕获
这是我的三个按钮的代码
-(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);
}
}