I have written this code to record video and would like to save the filePath to the documents directory, how can I do this?
func startRecording() {
var currentDateTime = NSDate()
var formatter = NSDateFormatter()
formatter.dateFormat = "MM-dd-yyyy, hh:mm:ss a"
var recordingName = formatter.stringFromDate(currentDateTime) + ".mp4"
var pathArray = [dirPath, recordingName]
let filePath = NSURL.fileURLWithPathComponents(pathArray)
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
videoRecorder = UIImagePickerController()
videoRecorder.delegate = self
videoRecorder.sourceType = UIImagePickerControllerSourceType.Camera
videoRecorder.mediaTypes = [kUTTypeMovie]
videoRecorder.videoMaximumDuration = 3600.0
videoRecorder.startVideoCapture()
}
}
I did this before, you can use NSFileHandle to do this
NSFileHandle(forWritingToURL: filePath, error: nil)
It works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.