title: How can I repeat a song in iOS?
body: <p>I am trying to repeat a song in my app. However, it just plays it until the end, then it stops altogether. How can I put in a loop feature for this?</p>
  
  <p>This is my code in my <code>viewDidLoad</code>:</p>
  
  <pre><code>    do
      {
          let audioPath = Bundle.main.path(forResource: "APP4", ofType: "mp3")
          try player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)
  
      }
  
      catch
  
      {
  
          //catch error
      }
  
      let session = AVAudioSession.sharedInstance()
  
      do
      {
  
          try session.setCategory(AVAudioSessionCategoryPlayback)
  
      }
  
      catch
      {
  
      }
            player.play()
  </code></pre>
  
  <p>I'm using Xcode 8.</p>