Posts

Post not yet marked as solved
0 Replies
309 Views
I'm having an issue where I can only use ReplayKit successfully once, then I have to restart the app to get it to work again. The first time I start recording, then stop. It works. The second time one of two things happen... I get a black screen in my preview I get the following error message in stopRecording(). Failed due to failure to process the first sample buffer After that, if I try to call startRecording again I get the following error. Recording failed to start Then the above error repeats until I restart my app. One other thing to note, the only time I get the alert to ask for approval to record is the first time I use ReplayKit. The alert doesn't show again until the first time after the app is restarted. Here are my functions I'm using. func didStartRecording() {     self.startRecording()   }       @objc func startRecording() {     let recorder = RPScreenRecorder.shared()     recorder.startRecording { [unowned self] (error) in       if let unwrappedError = error {         log.error("Error trying to record using ReplayKit: \(unwrappedError.localizedDescription)")         return       }               recordingView.backgroundColor = UIColor.red       self.view.addSubview(recordingView)       recordingView.snp.makeConstraints { make in         make.top.left.right.equalToSuperview()         make.height.equalTo(50)       }               let recordingLabel = InstrLabel()       recordingLabel.text = "Recording....Tap to stop"       recordingLabel.textColor = .white       recordingView.addSubview(recordingLabel)       recordingLabel.snp.makeConstraints { make in         make.width.height.equalToSuperview().multipliedBy(0.9)         make.centerX.centerY.equalToSuperview()       }               let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(stopRecording))       recordingLabel.isUserInteractionEnabled = true       recordingLabel.addGestureRecognizer(tapGestureRecognizer)     }   }       @objc func stopRecording() {     let recorder = RPScreenRecorder.shared()           recorder.stopRecording { [unowned self] (preview, error) in       DispatchQueue.main.async {         recordingView.removeFromSuperview()       }               if let error = error {         log.error("Error with stopping the recording: \(error.localizedDescription)")       }               if let unwrappedPreview = preview {         unwrappedPreview.previewControllerDelegate = self         self.pushViewController(unwrappedPreview, animated: true)       }     }   }   func previewControllerDidFinish(_ previewController: RPPreviewViewController) {     self.popViewController(animated: true)   } I'm using iPad 5th Generation 14.7.1 Is there anyway to reset the replaykit successfully so I can do another recording immediately after without restarting the app? I've seen a few other threads with the "black screen" but none of them had any solutions that I could find.
Posted
by tkell.
Last updated
.