title: Playing a sound with AVAudioPlayer
body: <p>I'm trying to play a sound with <code>AVAudioPlayer</code> but it won't work.</p>
  
  <p><strong>Edit 1:</strong> Still doesn't work.</p>
  
  <p><strong>Edit 2</strong>: This code works. My device was in silent mode.</p>
  
  <pre><code>import UIKit
  import AVFoundation
  
  class ViewController: UIViewController {
  
      var audioPlayer = AVAudioPlayer()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          var alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("button-09", ofType: "wav"))
          println(alertSound)
  
          var error:NSError?
          audioPlayer = AVAudioPlayer(contentsOfURL: alertSound, error: &amp;error)
          audioPlayer.prepareToPlay()
          audioPlayer.play()
      }
  }
  </code></pre>