需要访问iPhone使用的默认相机快门声音
现在,当用户按下一个button,我玩一个自定义相机快门声音。
但是,如果可能的话,我宁愿使用默认播放的相机快门声音,每当使用iPhone拍照时。
有没有一种方法可以访问和使用默认的iPhone相机快门声音? 如果是的话,那么它究竟在哪里?
我需要找出它的文件path,以便我可以使用下面的代码,只需更改pathForResource
的input:
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"shutter" ofType: @"wav"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath ]; self.myAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; [self.myAudioPlayer play];
谢谢您的帮助。
AudioServicesPlaySystemSound(1108);
基于: 是否有任何其他的iOS系统听起来不是“tock”? 和http://iphonedevwiki.net/index.php/AudioServices
2016年….
if #available(iOS 9.0, *) { AudioServicesPlaySystemSoundWithCompletion(SystemSoundID(1108), nil) } else { AudioServicesPlaySystemSound(1108) }