名为 SpeakHere 的 Apple 演示 iPhone 应用程序不会响应 kAudioSessionOverrideAudioRoute_None
我正在尝试 Apple 的示例应用程序 SpeakHere,并且想通过扬声器而不是耳机来收听。
我可以使用此代码打开免提扬声器:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
但此后应用程序将不再录音。它冻结了。这段代码没有任何用处:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
天哪,如果您可以使用顶部代码打开扬声器,那么您应该能够使用其他代码将其关闭。秘密是什么?
I was trying out Apple's sample app SpeakHere, and wanted to listen through the speakerphone speaker instead of the ear speaker.
I was able to turn on the speakerphone speaker using this code:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
But after that the app will no longer record. It freezes. This code doesn't do any good:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
Boy, it sure seems like if you can toggle the speaker on with top code, you ought to be able to toggle it off with the other code. What's the secret?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试在音频队列运行时执行此操作?或者您之前是否停止了音频队列并在更改音频会话后重新启动它?
您是否查看过所有音频会话和音频队列调用的错误返回值,以查看是否报告了错误?如果是这样,误差值是多少?
Are you trying to do this while your Audio Queue is running? Or did you stop the audio queue before and restart it after changing the audio session?
Have you looked at the error return values from all the audio session and audio queue calls to see if an error is being reported? And, if so, what is the error value?