Thanks for your reply.
but i still don't get it.
below is the way i activate the speaker.
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord ; // 1
AudioSessionSetProperty (
kAudioSessionProperty_AudioCategory, // 2
sizeof (sessionCategory), // 3
&sessionCategory // 4
);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; // 1
AudioSessionSetProperty (
kAudioSessionProperty_OverrideAudioRoute, // 2
sizeof (audioRouteOverride), // 3
&audioRouteOverride // 4
);
below is the way i deactivate the speaker
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None; // 1
AudioSessionSetProperty (
kAudioSessionProperty_OverrideAudioRoute, // 2
sizeof (audioRouteOverride), // 3
&audioRouteOverride // 4
);
when i tried to check the content of kAudioSessionProperty_AudioRoute as
NSLog(@"%@",kAudioSessionProperty_AudioRoute );
,the simulator crashed.
I look up the documentation, CFStringRef is almost the same with NSString type.
Therefore, it is reasonable to use NSLog to print the value of kAudioSessionProperty_AudioRoute.
As you said, kAudioSessionProperty_AudioRoute is supposed to be "headphone" or "speaker"
I still can not make if the code i paste is right and the way i activated speaker is right.
Can you help me?