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

参考链接:

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中。


D21EEFB8-8951-40CD-8886-C19ABBF132D2.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容