title: Unable to Play Audio Using AVAudioPlayer
body: <p>I am attempting to play an audio file using <code>AVAudioPlayer</code>. Previously, I was able to play audio successfully using the code:</p>
  
  <pre><code>// Play the audio file
  var soundID: SystemSoundID = 0
  let mainBundle: CFBundleRef = CFBundleGetMainBundle()
  // Get the audio reference
  if let ref: CFURLRef = CFBundleCopyResourceURL(mainBundle, filename, Globals.SOUND_TYPE, nil) {
      // Reference found, play audio
      AudioServicesCreateSystemSoundID(ref, &amp;soundID)
      AudioServicesPlaySystemSound(soundID)
  }
  </code></pre>
  
  <p>But a new requirement in the app is I will need to be able to play audio with a certain volume. <code>AudioServicesPlaySystemSound</code> is not able to give me that functionality. So now I have the following code:</p>
  
  <pre><code>do {
      let audioPlayer =  try AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(filename, ofType: Globals.SOUND_TYPE)!))
  
      audioPlayer.volume = volume
      audioPlayer.play()
      print("play audio")
  
  } catch {
      print("Error")
  }
  </code></pre>
  
  <p>I'm getting to the play audio <code>print</code> statement, but not audio is playing. I have even hardcoded <code>audioPlayer.volume = 1.0</code>, but no audio plays. What code could I be missing in order to play the audio?</p>