在一个视图控制器中捕获视频并尝试在另一个视频控制器中预览并上传它。一切正常,直到我尝试上传它给我文件不存在
VideoRecorderViewController.swift
func finishRecording(outputFileURL: URL!) {
DispatchQueue.main.async { [unowned self] in
let path = outputFileURL.path
if FileManager.default.fileExists(atPath: path) {
//it comes here
}
let vc: VideoViewController? = self.storyboard?.instantiateViewController(withIdentifier: "VideoVC") as? VideoViewController
if let validVC: VideoViewController = vc {
validVC.videoURL = outputFileURL as NSURL?
self.navigationController?.pushViewController(validVC, animated: true)
}
}
}
VideoViewController.swift
var videoURL = NSURL(string: "")
@IBAction func btnSave(_ sender: Any) {
print (self.videoURL!)
// returns file:///private/var/mobile/Containers/Data/Application/228FAD74-B7C3-4838-8114-ED16D995FF9A/tmp/3B256E17-9875-4610-B8B3-348FBFAEC409.mov
print (self.videoURL!.path!)
//returns /private/var/mobile/Containers/Data/Application/228FAD74-B7C3-4838-8114-ED16D995FF9A/tmp/3B256E17-9875-4610-B8B3-348FBFAEC409.mov
let path = self.videoURL!.path!
if FileManager.default.fileExists(atPath: path) {
// "never comes"
}
}