I am trying to play an audio in my project done in ios (swift language) .I can't play the audio due to the error
thread 1:EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0)
I can play the same audio when do it separate. But when I add it to my project getting the above mentioned error. I tried with different codes for playing audio. But the same error is repeating in the same line.
@IBAction func playaudio(sender:AnyObject)
{
var ButtonAudioPlayer: AVAudioplayer!
let path = NSBundle.mainBundle()pathResource("ButtonAudio.wav",ofType:nil)! // error
let url = NSURL(fileURLWithPath: path)
do
{
let ButtonAudioPlayer1 = try! AVAudioPlayer(contesOfURL:url)
ButtonAudioPlayer = ButtonAudioPlayer1
ButtonAudioPlayer1.play()
}
}