Need to access the default camera shutter sound used by the iPhone

核能气质少年 提交于 2019-11-30 17:26:06
AudioServicesPlaySystemSound(1108);

Based on: Are there any other iOS system sounds available other than 'tock'? and http://iphonedevwiki.net/index.php/AudioServices

For 2016 ....

    if #available(iOS 9.0, *) {
        AudioServicesPlaySystemSoundWithCompletion(SystemSoundID(1108), nil)
    } else {
        AudioServicesPlaySystemSound(1108)
    }

Looking at stevesliva's answer helped me greatly. However, I ended up with this:

Unexpected type name 'SystemSoundID': expected expression

... using this line...

AudioServicesPlaySystemSoundWithCompletion(SystemSoundID(1108), nil);

So, using this lump of code got my App playing the camera-shutter noise:

SystemSoundID soundID = 1108;

AudioServicesPlaySystemSoundWithCompletion(soundID, ^{
    AudioServicesDisposeSystemSoundID(soundID);
});

Hope this helps someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!