title: NSURLErrorDomain error -1 When trying to download http Live Streaming Video
body: <p>I have been trying to download a video from a url using the AVAssetDownloadDelegate. I am able to play the video from the response, but I am unable to download the media using the below code.</p>
  
  <p>I receive this error <strong>" The operation couldn’t be completed. (NSURLErrorDomain error -1.) "</strong></p>
  
  <p>This is the code i used</p>
  
  <pre><code>@IBOutlet weak var view1: UIView!
  
  var configuration : URLSessionConfiguration? = nil
  
  var downloadSession : AVAssetDownloadURLSession? = nil
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  
        configuration = URLSessionConfiguration.background(withIdentifier: "downloadIdentifier")
  
  
        downloadSession = AVAssetDownloadURLSession(configuration: configuration!,
                                                      assetDownloadDelegate: self,
                                                      delegateQueue: nil)
  
      let url = URL(string: "http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8")
      let asset = AVURLAsset(url: url!)
  
      let downloadTask = downloadSession?.makeAssetDownloadTask(asset: asset,
                                                                assetTitle: "assetTitle",
                                                                assetArtworkData: nil,
                                                                options: nil)
  
      // Start task and begin download
      downloadTask?.resume()
  
  
      let playerItem = AVPlayerItem(asset: (downloadTask?.urlAsset)!)
      let player = AVPlayer(playerItem: playerItem)
      let playerLayer = AVPlayerLayer(player: player)
      playerLayer.frame = view1.bounds
      view1.layer.addSublayer(playerLayer)
      player.play()
  
  
  }
  </code></pre>
  
  <p>This are the delegates I implemented</p>
  
  <pre><code>func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
      print("Downloaded to Location : \(location)")
  }
  
  
  
  func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didLoad timeRange: CMTimeRange, totalTimeRangesLoaded loadedTimeRanges: [NSValue], timeRangeExpectedToLoad: CMTimeRange) {
      var percentComplete = 0.0
      // Iterate through the loaded time ranges
      for value in loadedTimeRanges {
          // Unwrap the CMTimeRange from the NSValue
          let loadedTimeRange = value.timeRangeValue
          // Calculate the percentage of the total expected asset duration
          percentComplete += loadedTimeRange.duration.seconds / timeRangeExpectedToLoad.duration.seconds
      }
      print(percentComplete *= 100)
      // Update UI state: post notification, update KVO state, invoke callback, etc.
  }
  
  func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
  
  
      if (error != nil){
  
          print(error?.localizedDescription)
  
  
  
      }else{
  
          print("Error")
  
      }
  
  }
  </code></pre>
  
  <p>Please have a look at this..</p>