Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAsset Unsupported URL

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!)")
      }
    }
like image 264
cluelessatmaths Avatar asked Nov 27 '25 01:11

cluelessatmaths


1 Answers

You need to use URL(fileUrlWithPath:) instead of URL(string:)

like image 162
andrehungaro Avatar answered Nov 29 '25 16:11

andrehungaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!