我第一次在我的应用程序中捕获视频,但是当我开始捕获时,我希望该按钮单击声音作为 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/