I am trying to video capture an ARKIt app using ReplayKit. I have a record button, when pressed turned red and start recording, then pressed again to turn white and stop recording.
But the stopRecording method never worked on the first time.
if recorder.isAvailable {
recorder.delegate = self
if recorder.isRecording {
print("Recorder is recording...")
// Stop recording
recorder.stopRecording { previewController, error in
print("Stop recording...")
if let controller = previewController {
controller.previewControllerDelegate = self
self.present(controller, animated:true, completion:nil)
}
}
}
else {
// Start recording
recorder.startRecording { error in
print("Starting to record…")
if error == nil {
print("Start Recording…")
}
}
}
When first pressed (print "Press Record!"), I can see the recording started. Then when I pressed again, I can see that recorder.isRecording is entered, but the block in recorder.stopRecording does not work. I have to press again to start recording, then stop again before the recorder.stopRecording block is entered.
Any idea? Help is appreciated.
Press Record!
Starting to record…
Start Recording…
Press Record!
Recorder is recording...
Press Record!
Starting to record…
Start Recording…
Press Record!
Recorder is recording...