Playing Audio in Xcode7

后端 未结 2 989
一个人的身影
一个人的身影 2021-01-27 12:17

I\'m simply trying to play audio when I tap a button, but I get an error with this line of code.

ButtonAudioPlayer = AVAudioPlayer(contentsOfURL: ButtonAudioURL,         


        
2条回答
  •  后悔当初
    2021-01-27 12:35

    You need to use the new Swift 2 syntax by changing that line to

    ButtonAudioPlayer = try! AVAudioPlayer(contentsOfURL: ButtonAudioURL)
    

提交回复
热议问题