ios - ReplayKit 在应用程序的后台模式或应用程序外部停止屏幕录制?
问题描述
我已经在应用程序的前台模式下使用 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) {
}
}
}
解决方案
推荐阅读
- java - 如何从 AsyncTask 中的数据库类中获取对象?
- node.js - 如何在常规节点应用程序旁边运行strapi
- eclipse - 如何配置代码辅助,导入语句无通配符
- c# - C# - 从动态方法调用具有“参数字符串 []”的委托
- java - 如何从 Java 中的子类调用 int 或 string
- java - 带有 Spinner 的 AndroidStudio 对话框
- python - 如何解决导出到 csv 文件的 unicode 错误(python)
- macos - 如何制作一个非技术Mac用户可以通过双击下载和运行的脚本?
- data-structures - 有人可以检查 insertatend 函数发生了什么.. 它没有创建 main 函数中提到的所有块
- node.js - 将所有 API 请求保存到 mongoDB unitl 微服务已启动