Active Filters: ReplayKit

Topics

#20: ReplayKit 🎥

Topics

ReplayKit in iOS 9 allows you to record a movie of what's happening on screen in your app or game. Here's a quick example of how to use it:

import ReplayKit

class GameViewController: UIViewController {
  func startRecording() {
    let recorder = RPScreenRecorder.sharedRecorder()
    recorder.startRecordingWithMicrophoneEnabled(true)
  }

  func stopRecording() {
    let recorder = RPScreenRecorder.sharedRecorder()

    recorder.stopRecordingWithHandler { (previewVC, error) in
      if let vc = previewVC {
        self.presentViewController(
          vc, 
          animated: true, 
          completion: nil
        )
      }
    }
  }
}

  • Records app audio, optionally also records microphone audio. The user is given the chance to preview and, edit , and trim the video before exporting.
  • You can't access the movie file itself. After recording, user is shown an activity view controller, which you can add custom actions to.
  • Recording is polite to battery and performance.
  • Only works A7 and A8 devices.
  • Permission from the user is required to begin recording.
  • Recording automatically excludes system UI like notifications or keyboard entry.