Reputation: 2382
func startRecording() {
let recorder = RPScreenRecorder.shared()
recorder.startRecording(withMicrophoneEnabled: false, handler: { (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.videoRecButton.addTarget(self, action:#selector(self.stopRecording), for: .touchUpInside)
}
})
}
func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecording { [unowned self] (preview, error) in self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(self.startRecording))
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.present(unwrappedPreview, animated: true)
}
}
}
On recorder.startRecording() and recorder.stopRecording()... it generates error as "The operation couldn’t be completed. (com.apple.ReplayKit.RPRecordingErrorDomain error -5803.)"
also I'm not getting permission popup.
Upvotes: 2
Views: 1347
Reputation: 6876
The error code -5803 means RPRecordingErrorFailedToStart
(all error codes can be found here)
This post: https://stackoverflow.com/a/33627512/4063602
mentions that:
Apparently ReplayKit needs either A7 or A8 processor
To see if you are able to use ReplayKit on a device, you can use the property isAvailable
on RPScreenRecorder
. As it says in the documentation:
When set to true, the screen recorder is available for recording. Screen recording can be unavailable due to unsupported hardware, the user’s device displaying information over Airplay or through a TVOut session, or another app using the recorder.
Hope this helps.
Upvotes: 2