Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何在AVFoundation中暂停屏幕录制_Objective C_Macos_Avfoundation_Screen Recording - Fatal编程技术网

Objective c 如何在AVFoundation中暂停屏幕录制

Objective c 如何在AVFoundation中暂停屏幕录制,objective-c,macos,avfoundation,screen-recording,Objective C,Macos,Avfoundation,Screen Recording,在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 = AVCapt

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];        
}

但我无法获得暂停功能的逻辑。有人能告诉我如何在录音时实现暂停屏幕吗?

在下面的链接中找到问题的答案如果您在
SO
中提出任何问题,请查看您的格式,如果您已经找到问题帖子的答案作为答案。