编辑:这是使用代码IM
//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,completion: nil) alert.addAction(UIAlertAction(Title: "Try Again!",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!,completion: nil) }) alertController.addAction(vIEwAction) self.prevIEwVIEwController = prevIEwVIEwController! self.prevIEwVIEwController.modalPresentationStyle = UIModalPresentationStyle.fullScreen self.vIEw?.window?.rootVIEwController!.present(alertController,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,completion: nil) alert.addAction(UIAlertAction(Title: "Try Again!",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}我相信这是ReplayKit中的一个错误,我不知道是否已经解决了10.1或者10.1,但是值得尝试10.1测试版来看它是否解决了你的问题. 总结
以上是内存溢出为你收集整理的swift – replaykit是否允许录制屏幕,然后广播屏幕?全部内容,希望文章能够帮你解决swift – replaykit是否允许录制屏幕,然后广播屏幕?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)