重播工具可以录制屏幕并播放屏幕吗?

12

我有一个问题,在直播屏幕后,我尝试录制屏幕,但无法正常工作。当我录制屏幕并尝试进行直播时,同样的问题也会发生。顺便说一句,我不是在同时进行它们。这是在完成其中一个操作后,我尝试使用另一个操作。如果您需要查看代码或更多信息,请告诉我。我使用Swift 3,并使用新的重播套件框架。谢谢!

编辑:这是我正在使用的代码

//LIVE STREAM REPLAYKIT=====================================================================
func broadcastActivityViewController(_ broadcastAVC: RPBroadcastActivityViewController, didFinishWith broadcastController: RPBroadcastController?, error: Error?) {
    print("=====hello delegate \(broadcastController?.broadcastURL) (error)")

    self.broadcastController = broadcastController
    self.broadcastController?.delegate = self

    broadcastAVC.dismiss(animated: true) {
        self.broadcastController?.startBroadcast(handler: { error in

            print("start broadcast \(error)")
            print("\(broadcastController?.broadcastExtensionBundleID)")
            print("==url=\(broadcastController?.broadcastURL)")
            print("==serviceInfo=\(broadcastController?.serviceInfo)")

    //This is called when the broadcast is live

    })
  }
}


func broadcastController(_ broadcastController: RPBroadcastController, didFinishWithError error: Error?) {
    print("broadcastController====delegate")

    let alert = UIAlertController(title: "Alert", message: "There was an error broadcasting your screen. Please try again", preferredStyle: UIAlertControllerStyle.alert)

    // show the alert
    self.view!.window?.rootViewController!.present(alert, animated: true, completion: nil)

    alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.destructive, handler: { action in

        // add action
   }))
}



 func broadcastController(_ broadcastController: RPBroadcastController, didUpdateServiceInfo serviceInfo: [String : NSCoding & NSObjectProtocol]) {
    print("broadcastController====didUpdateServiceInfo")
  }

  //LIVE STREAM REPLAYKIT=========================================================


 //RECORD SCREEN REPLAYKIT-------------------------------------------------------------------
func startRecoding() {
    let recorder = RPScreenRecorder.shared()
    if recorder.isAvailable {
        recorder.startRecording(handler: { (error) in


   if error == nil { // Recording has started


    } else {
                // Handle error
                print("Dont Allow Recording")

    }
 })

    } else {
        print("Did not record screen")

        //if iphone or ipad doesnt support replaykit

        // create the alert
        let alert = UIAlertController(title: "Alert", message: "Please make sure your device supports ReplayKit!", preferredStyle: UIAlertControllerStyle.alert)


        // show the alert
        self.view!.window?.rootViewController!.present(alert, animated: true, completion: nil)

        alert.addAction(UIAlertAction(title: "Try Again!", style: UIAlertActionStyle.destructive, handler: { action in
            // add action

    }))
  }
}


func stopRecording() {

    let sharedRecorder = RPScreenRecorder.shared()
    sharedRecorder.stopRecording(handler: { (previewViewController: RPPreviewViewController?, error) in

 if previewViewController != nil {
            print("stopped recording")

            previewViewController!.previewControllerDelegate = self

            let alertController = UIAlertController(title: "Recording", message: "Tap view to watch, edit, share, or save your screen recording!", preferredStyle: .alert)

            let viewAction = UIAlertAction(title: "View", style: .default, handler: { (action: UIAlertAction) -> Void in

                self.view?.window?.rootViewController?.present(previewViewController!, animated: true, completion: nil)

 })

            alertController.addAction(viewAction)
            self.previewViewController = previewViewController!
            self.previewViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
            self.view?.window?.rootViewController!.present(alertController, animated: true, completion: nil)
 }


 else {
            print("recording stopped working")

            //create the alert================================

            let alert = UIAlertController(title: "Alert", message: "Sorry, there was an error recording your screen. Please Try Again!", preferredStyle: UIAlertControllerStyle.alert)

            // show the alert
            self.view!.window?.rootViewController!.present(alert, animated: true, completion: nil)

            alert.addAction(UIAlertAction(title: "Try Again!", style: UIAlertActionStyle.destructive, handler: { action in
                // add action

          }))
       }
   })
 }


func previewControllerDidFinish(_ previewViewController: RPPreviewViewController) {

print("cancel and save button pressed")

previewViewController.dismiss(animated: true, completion: nil)
//dismiss preview view controller when save or cancel button pressed

}

问题是在我广播屏幕后,我按停止,然后尝试录制屏幕,但它不起作用。我不想保存已广播的视频。我只想能够录制屏幕,录制结束后再广播屏幕。我不知道您是否看到了新的重播套件框架,但您可以录制屏幕并实时广播屏幕。我只是不知道是否允许在应用程序中同时使用两者。 - coding22
你需要在你的问题中包含一些代码。 - Lance
我现在不在家,但一旦回去就会联系您。 - coding22
@Lance,我已经添加了代码,请您看一下好吗? - coding22
听起来可能是一个bug,或者值得向苹果提交一个以进行检查。 - rickster
显示剩余2条评论
1个回答

1

我相信这是ReplayKit的一个错误,我不确定它是否在10.1中已解决,但值得尝试10.1测试版以查看是否解决了您的问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接