大佬教程收集整理的这篇文章主要介绍了swift – replaykit是否允许录制屏幕,然后广播屏幕?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
编辑:这是使用代码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 }
以上是大佬教程为你收集整理的swift – replaykit是否允许录制屏幕,然后广播屏幕?全部内容,希望文章能够帮你解决swift – replaykit是否允许录制屏幕,然后广播屏幕?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。