title: How to check AVAudioPlayer is still running?
body: <p>I am using AVAudioPlayer ,in my <strong>viewdidload</strong> method ,initially its running well ,but when i again coming to the same view controller that song starts running mingle with the initial song .</p>
  
  <p>so i am trying to find out is the song running at background?</p>
  
  <p>this is my function ,i am calling this function into the view did load</p>
  
  <pre><code>func prepareAudio()
      {
          if audioPlayer.playing
          {
              audioPlayer.stop()
          }
          do
          {
  
                  audioPlayer=try AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("Kids", ofType: ".mp3")!), fileTypeHint: AVFileTypeMPEGLayer3)
                  audioPlayer.delegate=self;
                  self.audioPlayer.play()
  
          }
          catch
          {
              print(error)
          }
  
      }
  </code></pre>
  
  <p>but while i am trying to run getting crash here 
  <strong><a href="https://i.stack.imgur.com/dqtiZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dqtiZ.png" alt="if audioPlayer.playing"></a></strong></p>
  
  <p>help me to find solution for this..</p>
  
  <p>2nd try</p>
  
  <p><a href="https://i.stack.imgur.com/cr3Bi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cr3Bi.png" alt="enter image description here"></a></p>
  
  <p>3rd try</p>
  
  <p><a href="https://i.stack.imgur.com/VyWCr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VyWCr.png" alt="enter image description here"></a></p>
  
  <p>4th try </p>
  
  <p><a href="https://i.stack.imgur.com/sW0JG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sW0JG.png" alt="enter image description here"></a></p>