I am trying to load a video downloaded from the internet stored in the Documents directory. However when I try I keep getting: error: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL"
let dstURL = URL(string: dstPath)!
let asset = AVAsset(url: dstURL)
asset.loadValuesAsynchronously(forKeys: ["tracks", "playable"]) {
var error: NSError?
let status = asset.statusOfValue(forKey: "tracks", error: &error)
if error != nil {
print("status: \(status), error: \(error!)")
}
}
You need to use URL(fileUrlWithPath:) instead of URL(string:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With