0
このコードは、押されたときに押す音のボタンに使用します。オン/オフ音(IOS)
「スイッチ」(2番目のVCにある)をオフにすると、最初のVCのボタンの音が消えますか?
@IBAction func SoundButton(_ sender: UIButton) {
let filename = "button-16"
let ext = "mp3"
if let soundUrl = Bundle.main.url(forResource: filename, withExtension: ext) {
var soundId: SystemSoundID = 0
AudioServicesCreateSystemSoundID(soundUrl as CFURL, &soundId)
AudioServicesAddSystemSoundCompletion(soundId, nil, nil, { (soundId, clientData) -> Void in
AudioServicesDisposeSystemSoundID(soundId)
}, nil)
AudioServicesPlaySystemSound(soundId)
}
}