我已经在应用程序的前台模式下使用ReplayKit实现了屏幕录制。但是,当我走出主页按钮时,应用程序会停止后台记录。 -> App Store中有一个可用的应用程序,它允许后台屏幕记录。 ->如果我必须使用广播上传和UI扩展,请提供一些编程指南。我已经在我的应用程序中添加了两者,但是仍然在后台模式下停止记录。
下面是我的代码
import UIKit
import ReplayKit
class ViewController: UIViewController {
let recorder = RPScreenRecorder.shared()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func btnStartRecord_Action(_ sender: UIButton) {
if recorder.isAvailable {
if !recorder.isRecording {
recorder.startRecording { (error) in
if let error = error {
print(error)
}
}
}
}
}
@IBAction func btnStopRecord_Action(_ sender: UIButton) {
if recorder.isAvailable {
if recorder.isRecording {
recorder.stopRecording { (previewVC, error) in
if let previewController = previewVC {
previewController.previewControllerDelegate = self
self.present(previewController, animated: true, completion: nil)
}
}
}
}
}
}
extension ViewController: RPPreviewViewControllerDelegate {
func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
previewController.dismiss(animated: true) {
}
}
}