ios - how to record screen video in swift? -
i doing guess song game app , need record screen when user guessing , capture device's audio output well. want app support ios8 , "replaykit" off table, sdk should use? beginner, if there's example code more help,thanks.
using apple's replaykit, can let user record gameplay, or in case, whatever user doing.
a link wwdc 2015 presentation included here
use these functions start , stop recording:
func startrecording() { let recorder = rpscreenrecorder.sharedrecorder() recorder.startrecordingwithmicrophoneenabled(true) { [unowned self] (error) in if let unwrappederror = error { print(unwrappederror.localizeddescription) } else { self.navigationitem.rightbarbuttonitem = uibarbuttonitem(title: "stop", style: .plain, target: self, action: "stoprecording") } } } func stoprecording() { let recorder = rpscreenrecorder.sharedrecorder() recorder.stoprecordingwithhandler { [unowned self] (preview, error) in self.navigationitem.rightbarbuttonitem = uibarbuttonitem(title: "start", style: .plain, target: self, action: "startrecording") if let unwrappedpreview = preview { unwrappedpreview.previewcontrollerdelegate = self self.presentviewcontroller(unwrappedpreview, animated: true, completion: nil) } } }
Comments
Post a Comment