mardi 4 août 2015

How to save video recording to documents directory with swift?

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()
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire