Created
December 14, 2018 05:41
-
-
Save SunXiaoShan/5f8c359b27fd39e2b7085e7b5d6a03af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func runRecording() { | |
guard recorder.isAvailable else { | |
print("Recording is not available at this time.") | |
return | |
} | |
recorder.startRecording{ [unowned self] (error) in | |
guard error == nil else { | |
print("There was an error starting the recording.") | |
return | |
} | |
} | |
} | |
func stopRecording() { | |
recorder.stopRecording { [unowned self] (preview, error) in | |
guard preview != nil else { | |
print("Preview controller is not available.") | |
return | |
} | |
let alert = UIAlertController(title: "Recording Finished", message: "Would you like to edit or delete your recording?", preferredStyle: .alert) | |
let deleteAction = UIAlertAction(title: "Delete", style: .destructive, handler: { (action: UIAlertAction) in | |
self.recorder.discardRecording(handler: { () -> Void in | |
print("Recording suffessfully deleted.") | |
}) | |
}) | |
let editAction = UIAlertAction(title: "Edit", style: .default, handler: { (action: UIAlertAction) -> Void in | |
preview?.previewControllerDelegate = self | |
self.present(preview!, animated: true, completion: nil) | |
}) | |
alert.addAction(editAction) | |
alert.addAction(deleteAction) | |
self.present(alert, animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment