我有一个计时器,可以根据输入进行倒计时。我希望它在达到0时播放拳击(圆角)声音。
我四处搜寻,发现了这个
// Load
let soundURL = NSBundle.mainBundle().URLForResource(mysoundname, withExtension: "wav")
var mySound: SystemSoundID = 0
AudioServicesCreateSystemSoundID(soundURL, &mySound)
// Play
AudioServicesPlaySystemSound(mySound);
我有以下问题:
提前致谢,
高手
最佳答案
我的代码:
// Load Sound
soundlocation = NSBundle.mainBundle().URLForResource("BoxingBellStart", withExtension: "wav")!
player = AVAudioPlayer(contentsOfURL: soundlocation, error: &Error)
player.volume = 1
// Play Sound
player.play()
BoxingBellStart是一个位于我项目中的.wav文件
关于ios - 使用NSTimer自定义声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28785249/