6

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

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

文件存在且有效(使用设备上的 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.")

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

4

0 回答 0