I need to save video captured with UIImagePicker to a custom folder in app document directory
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker.dismissViewControllerAnimated(true, completion: nil)
if let fileURL = info[UIImagePickerControllerMediaURL] as? NSURL {
if let videoData = NSData(contentsOfURL: fileURL) {
//save file to doc dir or save NSData into Core Data binary field
}
}
}
alternatively I can save videoData in Core Data binary field with external storage but after I can't play the video with media player because I can't convert NSData to NSURL.
Try this for Swift 3
Play the video
Try this. Swift 2.2
Now play the video.