iOS 12:ReplayKit损坏

时间:2018-09-28 08:40:55

标签: ios swift replaykit

我一直在使用ReplayKit进行所有以前的更新,但是现在在iOS 12上,我的录音有时可以正常工作,有时不起作用,但是通常不起作用。在大多数情况下,我停止录制后会得到以下信息:

全黑屏幕。

我以前从未发生过这种情况,这非常令人沮丧。这是我使用ReplayKit录制屏幕的方式:

import ReplayKit

class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, RPPreviewViewControllerDelegate {

func startRecording() {

    func start() {
        guard RPScreenRecorder.shared().isAvailable else {
            print("Recording is not available at this time.")
            return
        }
        RPScreenRecorder.shared().isMicrophoneEnabled = micToggle
        RPScreenRecorder.shared().startRecording { [unowned self] (error) in
            guard error == nil else {
                print("There was an error starting the recording.")
                return
            }
            print("Started Recording Successfully")
            isRecording = true
        }
    }
    DispatchQueue.main.async {
        start()
    }
}

func stopRecording() {

    func stop() {
        RPScreenRecorder.shared().stopRecording { [unowned self] (preview, error) in
            print("Stopped recording")
            guard preview != nil else {
                print("Preview controller is not available.")
                return
            }
            onGoingScene = true
            preview?.previewControllerDelegate = self
            self.present(preview!, animated: true, completion: nil)
            print("presented")
            isRecording = false
        }
    }
    DispatchQueue.main.async {
        stop()
    }
}

func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
    previewController.dismiss(animated: true, completion: nil)
    RPScreenRecorder.shared().discardRecording {
        print("discarded")
    }
}

工作时,将打印所有打印语句,但是当黑屏出现时,将显示“最后一个”打印语句。

我绝对渴望获得帮助,因为我不知道该如何解决。任何帮助将不胜感激。

谢谢


编辑: 我只是意识到我可能正在使用“ AVCaptureVideoPreviewLayer”。如果是这样,解决办法是什么?

0 个答案:

没有答案