gpt4 book ai didi

ios - 需要访问 iPhone 使用的默认相机快门声音

转载 作者:技术小花猫 更新时间:2023-10-29 10:06:34 36 4
gpt4 key购买 nike

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

但是,如果可能的话,我宁愿只使用当您使用 iPhone 拍照时默认播放的相机快门声音。

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

我需要弄清楚它的文件路径,以便我可以将它与下面的代码一起使用,只需更改 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);

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

2016 年....

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

关于ios - 需要访问 iPhone 使用的默认相机快门声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22850002/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com