AVURLAsset not loading video on documents folder, even using fileURLWithPath

安稳与你 提交于 2019-12-07 06:05:38

问题


been struggling with this for the past couple of hours, hopefully someone has run into it before

I download a file that from a server to my documents folder

File is there and valid (checked with iExplorer on device and the local directory of the simulator). Moved each file to my desktop and plays without problems.

The strange thing is that the exact same code works without issues when the file (the same video) is added to the bundled.

code:

print("video url string   :   \(video.urlString)")   
// prints: /var/mobile/Containers/Data/Application/47AC756B-7A00-4FAE-9348-214972BE61BD/Documents/demo-reel.mp4
// file IS there

let asset = AVURLAsset(URL: NSURL(fileURLWithPath: video.urlString))
let keys = ["tracks","playable","duration"]

asset.loadValuesAsynchronouslyForKeys(keys, completionHandler: { () -> Void in
                var error : NSError? = nil
            let status = asset.statusOfValueForKey("tracks", error: &error)

            switch status {
            case .Failed:
                print("failed \(error?.localizedDescription)")
            case .Loaded:                  
                print("loaded \(error?.localizedDescription)")
            case .Loading:
                print("loading \(error?.localizedDescription)")
            case .Cancelled:
                print("cancelled \(error?.localizedDescription)")
            case .Unknown:
                print("unknown \(error?.localizedDescription)")


            }

prints: failed Optional("The requested URL was not found on this server.")

am i missing something? help is appreciated

来源:https://stackoverflow.com/questions/35532247/avurlasset-not-loading-video-on-documents-folder-even-using-fileurlwithpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!