Swift AVAudioPlayer doesn't play sound

Question!

I want to play two sound files in my Swift app. "C1_bip.aif" and "false.aif". They're both in the same folder in the project.

But when I start the app, the C1_bip sound is played and the false sound not and it prints Error to the Console.

The sound files are the same file type and I can play them both in the project explorer in Xcode.

if let path = NSBundle.mainBundle().pathForResource("C1_bip", ofType: "aif") {
        audioPlayer = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: path), 
        fileTypeHint: "aif", error: nil)

        if let sound = audioPlayer {

            sound.prepareToPlay()
            sound.play()
        }
    }
    else {
        println("Error")
    }



   if let path = NSBundle.mainBundle().pathForResource("false", ofType: "aif") {
        audioPlayer = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: path), 
        fileTypeHint: "aif", error: nil)

        if let sound = audioPlayer {

            sound.prepareToPlay()
            sound.play()
        }
    }
    else {
        println("Error")
    }


This video can help you solving your question :)
By: admin