title: how to run progress bar until the background plying audio stoped
body: <p>i'm working on a audio player  where i have to allow the audio to play in background, i have done with audio sessions but i stuck in progress bar when i play audio in background and again open my app the progress bar and timer stoped, i need to run them also in background. i mean progress bar should be updated with timer if i move to other views or minimise the app.</p>
  
  <pre><code> @IBAction func btnPlayMusicAction(_ sender: Any)
  {
      if isPlaying == false {
          self.btnPlayMusicPro.setImage(#imageLiteral(resourceName: "PauseIcon"), for: .normal)
          self.isPlaying = true
          self.audioPlayer?.play()
          timer = Timer.scheduledTimer(timeInterval:1.0, target: self,selector: (#selector(updateRemainingTime)), userInfo: nil, repeats:true)
  
  
  
      }else{
          self.btnPlayMusicPro.setImage(#imageLiteral(resourceName: "PlayIcon"), for: .normal)
          self.isPlaying = false
          if (audioPlayer?.isPlaying)!{
              self.audioPlayer?.pause()
          }
          self.timer?.invalidate()
  
  
  
      }
  }
  </code></pre>
  
  <p>her is the method updateRemainingTime()</p>
  
  <pre><code>    @objc func updateRemainingTime(){
      let currentTime =   Int((audioPlayer?.currentTime)!)
      let duration = Int((audioPlayer?.duration)!)
      let seconds = currentTime % 60
      let minutes = (currentTime / 60) % 60
      let hours = (currentTime / 3600)
  
      var remainingTime:String = ""
      if currentTime &gt;= 3600{
          remainingTime = String(format: "%02d:%02d:%02d", hours, minutes, seconds)
      }else{
          remainingTime = String(format: "%02d:%02d", minutes, seconds)
      }
  
      self.lblPlayMusicTimePro.text = remainingTime
      Tray.remainingAudioTime = remainingTime
  
      if currentTime  == duration-1{
          timer?.invalidate()
  
          if (audioPlayer?.isPlaying)!{
              self.audioPlayer?.currentTime = 0
              self.audioPlayer?.stop()
          }
          self.btnPlayMusicPro.setImage(#imageLiteral(resourceName: "PlayIcon"), for: .normal)
          self.isPlaying = false
          self.musicProgressViewPro.setProgress(0.0, animated: true)
          self.lblPlayMusicTimePro.text = "00:00"
          self.lblMusicTimePro.text = "00:00"
      }else {
          let currentProgress = Float((audioPlayer?.currentTime)! / (audioPlayer?.duration)!)
          Tray.progressTime = currentProgress
          self.musicProgressViewPro.setProgress(currentProgress, animated: true)
  
      }
  }
  </code></pre>