iphone - 开始录音时发出提示音

标签 iphone ios objective-c ipad

我第一次在我的应用程序中捕获视频,但是当我开始捕获时,我希望该按钮单击声音作为 native 应用程序。我查了很多资料,才知道是系统声音。谁能告诉我当我开始捕捉视频和停止捕捉时如何在我的应用程序中添加声音。

目前我正在使用 AVAudioPlayer 播放声音,如下所示

  NSURL *url1 = [[NSBundle mainBundle] URLForResource:str withExtension:@"wav"];
_startAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url1 error:nil];
_startAudioPlayer.delegate= self;
[_startAudioPlayer prepareToPlay];
[_startAudioPlayer play];

提前致谢......

最佳答案

只需导入AudioToolbox.framework
创建源音频文件的 URL

NSURL *tapSound   = [[NSBundle mainBundle] URLForResource: @"tap"
                                                withExtension: @"aif"];


// Store the URL as a CFURLRef instance
self.soundFileURLRef = (CFURLRef) [tapSound retain];

// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID (
    soundFileURLRef,
    &soundFileObject
);

播放声音

AudioServicesPlayAlertSound (soundFileObject);

这是一个很好的教程 link你可以关注这个

关于iphone - 开始录音时发出提示音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15965576/

相关文章:

ios - 如何在 iPhone 特定项目中创建 iPad xib 文件

iphone - 无法在 xcode 中生成 iOS App 存档

iphone - OpenCV视频处理教程问题

ios - cell.detailTextLabel.text 的问题(无重复)

objective-c - 相似的代码行,截然不同的性能

objective-c - 如何一次关闭 3 个模态视图 Controller ?

iphone - 如何从 Objective-C 计算我的应用程序安装日期和设备日期之间的日期计数差异

ios - 设置基于 View Controller 的状态栏外观时,StatusBar 不会调用 preferredStatusBarStyle = YES

ios - 自定义单元格中未调用 UITableView didSelectRowAt indexPath

iOS 横向 View 在键盘显示时移动文本字段