Как приостановить запись экрана в AVFoundation

Мне нужно реализовать экран паузы во время записи с 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];        
}

Но я не могу получить логику для функции паузы. Может ли кто-нибудь сказать мне, как я могу реализовать паузу экрана при записи?


person Gauri rawat    schedule 23.12.2013    source источник
comment
Найдите ответ на свой вопрос по ссылке ниже stackoverflow.com/ вопросы/15097320/   -  person Vaz    schedule 23.12.2013
comment
Посмотрите на свое форматирование, если вы что-то спрашиваете в SO и если вы уже нашли ответ на свой вопрос как ответ.   -  person Alex Cio    schedule 04.02.2014