捕获的Swift视频文件不存在于另一个视图控制器中

时间:2016-12-09 05:04:32

标签: ios swift

在一个视图控制器中捕获视频并尝试在另一个视频控制器中预览并上传它。一切正常,直到我尝试上传它给我文件不存在

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"


                }

    }

0 个答案:

没有答案