2016-09-25 18 views
10

私はスクリーンライブをブロードキャストした後、画面を録画しようとしたが動作しないという問題がありました。私の画面を録画してから画面をライブで放送しようとすると、同じことが起こります。私は一緒にbtwをしようとしないでください。これは1つが完了した後で、もう1つを使用しようとします。あなたがコードや詳細を見る必要があるかどうかを教えてください。 Im in Swift 3と新しいリプレイキットフレームワークを使用しています。ありがとう!replaykitは画面を録画して画面をブロードキャストできますか?

EDIT:これは私は、これはReplayKitのバグであると信じている

//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 

} 
+0

画面がブロードキャストされ、プレーヤーが終了し、ブロードキャストされたビデオをディスクに保存することを明確にしてください。 – Lance

+0

問題は私が画面を放送し終えた後に停止を押してから画面を録画しようとしても動作しないことです。私は放送されたビデオを保存したくありません。私はちょうど画面を録画できるようにしたい、それが終わったらスクリーンを放送する。あなたが新しいリプレイキットのフレームワークを見たかどうかわかりませんが、画面を録画して画面をライブ放送することもできます。私はそれがアプリケーションで両方を使用することが許可されている場合はわかりません。 – coding22

+0

どちらもうまく動作しますが、私はそれを背中合わせにします。私が画面を最初に記録したようにして、それから画面をライブ放送したいと思うように、それは動作しません。同じことが起こるのは、画面を最初にライブブロードキャストする場所を逆にした場合です。最初は動作しますが、画面を記録しようとすると動作しません。なぜそれが起こるのか分かりません。 – coding22

答えて

1

を使用してコードIMですが、私はそれが10.1かのように解決されたかどうかわからないんだけど、それは試してみる価値あり10.1ベータ版があなたの問題を解決するかどうかを確認してください。

関連する問題