App的音频无法通过扬声器工作 [英] App's audio not working through speakers

查看:239
本文介绍了App的音频无法通过扬声器工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个奇怪的错误。我正在使用AVAudioPlayer播放声音(它的多个实例),声音通过耳机完美运行,但使用没有耳机的应用程序不会产生扬声器发出的声音。所有音频片段都是AAC编码的。

There's a weird bug in my app. I'm using AVAudioPlayer to play sounds (multiple instances of it), the sound works perfectly through headphones, but using the app without headphones produces no sound from the speaker. All of the audio clips are AAC encoded.

我尝试通过Objective-C API([AVAudioSession sharedInstance])和C API设置AVAudioSession属性,但是没有一个选项似乎有效。

I have tried setting the AVAudioSession properties both through the Objective-C API ([AVAudioSession sharedInstance]) and the C API, but none of the the options seem to work.

推荐答案

iPhone上的问题 - 当声音非常低时 - 似乎它出来了手机耳机(不是
耳机插孔)而不是底部扬声器 - 更改为默认发言人

ISSUE on iPhone - when sound was very low - seemed it was coming out the phone ear piece (not headphone jack) instead of bottom speaker - change to DEFAULT TO SPEAKER

//http://stackoverflow.com/questions/3104562/avaudiorecorder-avaudioplayer-sound-output-on-internal-speaker-how-to-chang


UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (
    kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
    sizeof (doChangeDefaultRoute),
    &doChangeDefaultRoute
);

这篇关于App的音频无法通过扬声器工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆