需要访问iPhone使用的默认相机快门声音 [英] Need to access the default camera shutter sound used by the iPhone

查看:407
本文介绍了需要访问iPhone使用的默认相机快门声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,当用户按下按钮时,我会播放自定义相机快门声。

Right now when a user presses a button I play a custom camera shutter sound.

然而,如果可能的话,我宁愿只使用你在使用iPhone拍照时默认播放的相机快门声。

However, if possible, I would much rather just use the camera shutter sound that plays by default whenever you take a photo using your iPhone.

有没有办法可以访问并使用默认的iPhone相机快门声?如果是,那么它实际位于何处?

Is there a way that I can access and use the default iPhone camera shutter sound? And if yes, then where is it actually located?

我需要弄清楚它的文件路径,以便我可以将它与下面的代码一起使用,只需更改输入 pathForResource

I need to figure out it's file path so that I can use it with the code below and just change the input for pathForResource:

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);

基于:
除了'tock'之外还有其他任何iOS系统声音吗?

http://iphonedevwiki.net/index.php/AudioServices

2016年....

For 2016 ....

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

这篇关于需要访问iPhone使用的默认相机快门声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆