开发者

Audio Volume in Apple's speakHere example code

开发者 https://www.devze.com 2022-12-12 23:02 出处:网络
I am trying to increase the volume of my Audio Output using the speakHere example from Apple. The volume is already set to max with :

I am trying to increase the volume of my Audio Output using the speakHere example from Apple. The volume is already set to max with :

// set the volume of the queue XThrowIfError (AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0), "set queue volume");

However, the output is directed to the ear-piece speaker, which is not as loud as the bottom-left-speaker on the iPhone. An example of this can be seen nicely in the 'Voice Memos' that comes with the iPhone. They provide a 'Speaker-Button' that toggles between the two speakers. Does anybody hav开发者_运维问答e an idea how that is done? What do I need to output my Audio to the bottom speaker? Any tips, hints, answers will be much appreciated. Thanks you in advance Al


You need to set Player to Speaker Mode.

Add this code in AQPlayer.mm:

OSStatus error;
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; 
error = AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
if (error) printf("couldn't set audio speaker!");

Before this code:

XThrowIfError (AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0), "set queue volume");

I hope it helps.


Take a look at AudioSessionSetProperty, the kAudioSessionProperty_OverrideCategoryDefaultToSpeaker property in particular.


look at the kAudioSessionProperty_OverrideAudioRoute property

0

精彩评论

暂无评论...
验证码 换一张
取 消