Quiet Audio on iPhone

Hi,

I am experiencing very quiet audio through the speakers for my app on iPhone (tested on a 4s and 5s), but it works fine on iPad (tested on an iPad 2). It also works fine if I have headphones plugged in. All 3 devices are running iOS 7. My app uses Cocos2x-x v2.x. The iPhones run other apps, such as Angry Birds, at normal volume through speaker, which makes me think it’s something to do with my app and, by extension, Cocos.

Has anyone experienced this?

Hello,

I encountered that problem once. I don’t remember the specifics, but the problem was about the audio session, which was not properly configured: it was using the “phone” mode (when you phone someone and have your phone glued to your ear), instead of the “speaker” mode (when your phone is not on your ear).

The first mode is way lower, for obvious reasons, and works only on iPhones, obviously.

Can you post the code about how you initialize your audio ?

Note: this may also be due to some other libraries or other code, I think the audio session is shared for all the app. Any audio session initialization is relevant.

Not sure if you mean initialise my audio files or initialise the audio engine, but I don’t think I manually initialise the audio engine. (Would get initialised when using getInstance()/sharedEngine()?)

I use the SimpleAudioEngine in Cocos v2.x (using Javascript) and just preload the audio I will use it and then play it when I need it. So, if I wanted to play a sound, I would use:

cc.AudioEngine.getInstance().preloadEffect(audioFile);
cc.AudioEngine.getInstance().playEffect(audioFile, false);

I don’t think I have changed any Cocos audio code.

Does iOS tell Cocos that it is in “phone” mode and Cocos reduces its volume, or does iOS automatically reduce the volume of the app by itself?

I was talking about audio engine initialization.

iOS automatically reduce the volume because it is not configured the way you want it.

Here is a relevant link that explains it better: http://stackoverflow.com/questions/18807157/how-do-i-route-audio-to-speaker-without-using-audiosessionsetproperty/18808124#18808124

That seems to work. Thanks.