我正在try 捕捉AVFoundation captureStillImageAsynchronouslyFromConnection相机实况预览过程中的图像.到目前为止,该计划的工作情况与预期一致.但是,我怎样才能使快门声音静音呢?
我正在try 捕捉AVFoundation captureStillImageAsynchronouslyFromConnection相机实况预览过程中的图像.到目前为止,该计划的工作情况与预期一致.但是,我怎样才能使快门声音静音呢?
我曾使用此代码捕获iOS默认快门声音(以下是声音文件名列表https://github.com/TUNER88/iOSSystemSoundsLibrary):
NSString *path = @"/System/Library/Audio/UISounds/photoShutter.caf";
NSString *docs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSData *data = [NSData dataWithContentsOfFile:path];
[data writeToFile:[docs stringByAppendingPathComponent:@"photoShutter.caf"] atomically:YES];
然后,我使用第三方应用程序从Documents目录(DiskAid For Mac)中提取了photoShutter.caf
个.下一步,我在Audacity音频编辑器中打开photoShutter.caf
,并应用反转效果,在高变焦时看起来是这样的:
然后我将此声音保存为photoShutter2.caf
,并try 在captureStillImageAsynchronouslyFromConnection
之前播放此声音:
static SystemSoundID soundID = 0;
if (soundID == 0) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"photoShutter2" ofType:@"caf"];
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
}
AudioServicesPlaySystemSound(soundID);
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:
...
这真的很管用!我运行了几次测试,每次都没有听到快门声音:)
你可以在iPhone 5S iOS 7.1.1上通过以下链接获得已经倒置的声音:https://www.dropbox.com/s/1echsi6ivbb85bv/photoShutter2.caf