我必须在AVFoundation
cocoa
进行录制时实施暂停屏幕
对于开始视频我正在使用此功能:
-(void)takeScreenRecording:(CGRect)rect saveAtPath:(NSURL*)destPath {
// Create a capture session
mSession = [[AVCaptureSession alloc] init];
// Set the session preset as you wish
mSession.sessionPreset = AVCaptureSessionPresetPhoto;
CGDirectDisplayID displayId = kCGDirectMainDisplay;
// Create a ScreenInput with the display and add it to the session
AVCaptureScreenInput *input =
[[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
[input setCropRect:rect];
if (!input) {
mSession = nil;
return;
}
if ([mSession canAddInput:input])
[mSession addInput:input];
// Create a MovieFileOutput and add it to the session
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([mSession canAddOutput:mMovieFileOutput])
[mSession addOutput:mMovieFileOutput];
// Start running the session
[mSession startRunning];
// Delete any existing movie file first
if ([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]])
{
NSError *err;
if ( ![[NSFileManager defaultManager] removeItemAtPath:[destPath path]
error:&err] )
{
NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
}
}
[mMovieFileOutput startRecordingToOutputFileURL:destPath
recordingDelegate:self];
}
停止屏幕录制我正在使用这些功能:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error {
NSLog(@"Did finish recording to %@ due to error %@",
[outputFileURL description], [error description]);
[mSession stopRunning];
mSession = nil;
}
-(void)finishRecord {
// Stop recording to the destination movie file
NSLog(@"Stopping record");
[mMovieFileOutput stopRecording];
}
但我无法获得暂停功能的逻辑。谁能告诉我如何在录制时实现暂停画面?