5

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

しかし、一時停止機能のロジックを取得できません。記録時に一時停止画面を実装する方法を誰か教えてもらえますか?

4

0 に答える 0