即使使用fileURLWithPath,AVURLAsset也不会在文档文件夹上加载视频

Dav*_*mes 5 avfoundation ios avurlasset swift avkit

在过去的几个小时里一直在努力解决这个问题,希望之前有人遇到过这个问题

我下载了一个从服务器到我的文档文件夹的文件

文件存在且有效(在设备上使用iExplorer和模拟器的本地目录进行检查).将每个文件移动到我的桌面并播放没有问题.

奇怪的是,当文件(相同的视频)被添加到捆绑包时,完全相同的代码可以正常工作.

码:

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.")
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?帮助表示赞赏