title: How to pause screen recording in AVFoundation
body: <p>I have to implement a pause screen while recording with <code>AVFoundation</code> in <code>cocoa</code></p>
  
  <p>For starting video I am using this function:</p>
  
  <pre><code>-(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:&amp;err]            )
          {
              NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
          }
      }       
  
      [mMovieFileOutput startRecordingToOutputFileURL:destPath 
                                    recordingDelegate:self];
  }
  </code></pre>
  
  <p>For stopping Screen recording I am using these functions:</p>
  
  <pre><code>- (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];        
  }
  </code></pre>
  
  <p>But I am unable to get logic for pause functionality. Can anyone tell me how I can implement a pause Screen when recording?</p>