关闭自定义相机拍照时声音

参考链接:

http://stackoverflow.com/questions/4401232/avfoundation-how-to-turn-off-the-shutter-sound-when-capturestillimageasynchrono

居然是同时播放一个与拍照声相反的声音,中和掉拍照声。

if (soundID == 0) {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"photoShutter2" ofType:@"caf"];
        NSURL *filePath = [NSURL fileURLWithPath:path];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
    }
    AudioServicesPlaySystemSound(soundID);

这段代码写在

[self.ImageOutPut captureStillImageAsynchronouslyFromConnection

前面。

下载photoShutter2.caf的地址参考

http://www.cocoachina.com/bbs/read.php?tid-1681579-toread-1-page-1.html

题外话~
运行时在

NSURL *filePath = [NSURL fileURLWithPath:path];

崩溃掉了,原来是path=nil。原因是我导入photoShutter2.caf时忘了添加到工程下面。

06496721-3B0F-4A90-A2DF-1633FA5E0292.png

解决办法除了重新导入,简单的就是把photoShutter2.caf添加到Copy BundleResources中。


关闭自定义相机拍照时声音_第1张图片
D21EEFB8-8951-40CD-8886-C19ABBF132D2.png

你可能感兴趣的:(关闭自定义相机拍照时声音)