title: How play audio while downloading from url?
body: <p>I need to create audio player. I get audio from url and i download audio from url then i play it. But i need play audio while audio  downloading how i can do this?</p>
  
  <p>This is my code how play it from url:</p>
  
  <pre><code> func URLSession(session: NSURLSession,
                  downloadTask: NSURLSessionDownloadTask,
                  didFinishDownloadingToURL location: NSURL){
      do {
          loadingView.hidden=true
          actInd.stopAnimating()
          UIApplication.sharedApplication().networkActivityIndicatorVisible = false
          player=try AVAudioPlayer(contentsOfURL: location)
          player?.delegate=self
          selectedAudio.status=true
          selectedAudio.isDownload=true
          player?.enableRate=true
          switch speedType_Index {
          case 0:
              appDelegate.player?.rate=Float(1)
              break
          case 1:
              appDelegate.player?.rate=Float(1.5)
              break
          case 2:
              appDelegate.player?.rate=Float(2)
              break
          case 3:
              appDelegate.player?.rate=Float(0.5)
              break
          default:
              break
          }
          switch playingType_Index {
          case 0:
              appDelegate.player?.numberOfLoops = 0
              break
          case 1:
              appDelegate.player?.numberOfLoops = -1
              break
          default:
              break
          }
          player?.volume=Float(volume)
          player?.play()
          self.tableView.reloadData()
  
      }catch let error as NSError{
          print(error.localizedDescription)
      }
  }
  
  func URLSession(session: NSURLSession,
                  downloadTask: NSURLSessionDownloadTask,
                  didWriteData bytesWritten: Int64,
                               totalBytesWritten: Int64,
                               totalBytesExpectedToWrite: Int64){
      let progress=Float(totalBytesWritten) / Float(totalBytesExpectedToWrite);
      bite.text=String(format: "%.1f%%",progress * 100)
  }
  </code></pre>