iPhone PlayAndRecord 使所有系统音频静音?
在我的 iPhone 应用程序中,我尝试同时录制音频和播放 iPod 音乐,因此我将音频会话类别设置为 kAudioSessionCategory_PlayAndRecord。但是当我设置这个时,所有系统音频(包括振动)都不再工作,尽管 iPod 音频仍然可以工作。有谁知道这是否是 SDK 中的错误或其他问题,或者如何解决它?请帮忙!
提前致谢!
In my iPhone app I am trying to record audio and play iPod music at the same time, so I set the audio session category to kAudioSessionCategory_PlayAndRecord. But when I set this, all system audio (including vibrate) doesn't work anymore, although the iPod audio still does work. Does anyone know if this is a bug in the SDK or something, or how to get around it? Please help!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 kAudioSessionOverrideAudioRoute 的文档告诉我们,PlayAndRecord 类别的默认设置是将音频路由到接收器(打电话时使用的扬声器)。有没有可能所有的音频都被路由到那里,而你不把耳朵放在那里就听不到?
如果您想更改音频的去向,您需要调用 AudioSessionSetProperty,并向其传递指定音频去向的常量。这些常量是
kAudioSessionOverrideAudioRoute_None,它指定您希望将音频路由到接收器(就像现在一样),或
kAudioSessionOverrideAudioRoute_Speaker,它指定音频应该路由到手机底部的扬声器
Looking at the documentation for kAudioSessionOverrideAudioRoute tells us that the default for the category PlayAndRecord is to route the audio to the receiver (the speaker used when you're talking on the phone). Is it possible that all the audio is being routed to that and you just can't hear without putting your ear there?
If you want to change where the audio is going you need to call AudioSessionSetProperty, and pass it the constant specifying where you want the audio to go. These constants are
kAudioSessionOverrideAudioRoute_None, which specifies that you wish the audio to be routed to the receiver (as it is now), or
kAudioSessionOverrideAudioRoute_Speaker, which specifies that audio should be routed to the speaker at the bottom of the phone