AVAudioPlayer 在 iPhone 上非常安静,但在 iPod touch 上声音足够大
当使用 AVAudioRecorder 注册噪音时,我有一些循环播放的声音。
这是我的代码:
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"foghornRepeat2" ofType:@"aif"];
foghornRepeat =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToFile] error:nil];
//foghornRepeat.delegate = self;
[foghornRepeat prepareToPlay];
foghornRepeat.numberOfLoops = -1;
[foghornRepeat setVolume:1];
然后当通过麦克风注册声音时播放和停止。知道为什么 iPhone 上会非常安静吗?在我的 iPod touch 上没问题。
我还有其他方法可以做到这一点吗?
谢谢 汤姆
I have some sound that is played in a loop as a noise is registered using an AVAudioRecorder.
Here is my code:
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"foghornRepeat2" ofType:@"aif"];
foghornRepeat =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToFile] error:nil];
//foghornRepeat.delegate = self;
[foghornRepeat prepareToPlay];
foghornRepeat.numberOfLoops = -1;
[foghornRepeat setVolume:1];
It is then played and stopped when sound is registered through the microphone. Any idea why this would be really quiet on an iphone? Its fine on my ipod touch.
Is there any other way I can do this?
Thanks
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能发生的情况是 iPhone 上的音频重新路由到手机扬声器。为了确保声音从真实的扬声器中播放,请在播放音效之前使用以下代码:
What probably happened is that the audio on your iphone rerouted to the phone speakers. To make sure the sound plays from the real speakers, use the following code before you play a sound effect: