2016-09-25 1 views
10

Im 화면을 실시간으로 방송 한 후 화면을 녹화하려고 시도하지만 작동하지 않는 문제가 있습니다. 내 화면을 녹화 한 다음 화면을 실시간으로 방송하려고 할 때도 똑같은 일이 발생합니다. 그들이 함께 btw하려고하지 않는 임. 이것은 하나가 완료된 후이고 다른 하나를 사용하려고합니다. 코드 또는 추가 정보가 필요한지 알려주십시오. 3 번 스위프트에서 새로운 리플레이 키트 프레임 워크 사용하기. 감사!replaykit에서 화면을 녹화 한 다음 화면을 브로드 캐스트 할 수 있습니까?

편집 :이 10.1 여부를 기준으로 해결 된 경우에, 잘 모르겠어요 내가이 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, 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

이지만, 그것은 시도 가치가있다 10.1 베타 테스트를 통해 문제가 해결되는지 확인하십시오.