AVURLAsset not loading video on documents folder, even using fileURLWithPath

622 views Asked by At

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

0

There are 0 answers