如何将 AVAudioPlayer 输出到扬声器 [英] How to get AVAudioPlayer output to the speaker
本文介绍了如何将 AVAudioPlayer 输出到扬声器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 AVAudioRecorder 录制音频,如 如何使用 AVAudioRecorder 在 iPhone 上录制音频?
I'm recording audio with AVAudioRecorder as seen in How do I record audio on iPhone with AVAudioRecorder?
然后我使用 AVAudioPlayer 播放录音.然而,声音是从耳机传出来的,而不是外放.我将如何将声音重定向到扬声器?
I then use AVAudioPlayer to play back the recording. However the sound is coming out of the ear speaker, not the loud speaker. How would I go about redirecting the sound to the loud speaker ?
TIA!
推荐答案
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
这篇关于如何将 AVAudioPlayer 输出到扬声器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文