ReplayKit stops screen recording in background mode of the application or outside the app?

旧时模样 提交于 2019-12-12 09:51:34

问题


I've implemented screen recording with ReplayKit in foreground mode of the application. But when I'm going outside the app with home button app stops background record. --> There is an app available In App Store which allows background screen record. --> If I have to use Broadcast upload and UI extension then please provide me some programming guide. I've added both in my app but still it stops recording in background mode.

Below is my code

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) {

    }
}
}

来源:https://stackoverflow.com/questions/53275187/replaykit-stops-screen-recording-in-background-mode-of-the-application-or-outsid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!