How to get AVAudioPlayer output to Speaker and verify if i am right on iphone simulator? -


I get some questions on playback music through the speaker. I got an example in the following link but the question is how to ensure Do I successfully implement the music through "speaker"? I've written the code as a link, but I do not mind before and after the "speaker" activation on the iPhone Simulator (MacBook)! !!

Update:

The way I activate the speaker below.

  UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord; // 1 Audio SessionProperty (kAudioSessionProperty_AudioCategory, // 2 sizeof (sessionCategory), // 3 and Session Category / 4); UIant32 audio routerride = audio session of thyroid audio spark; // 1 AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, // 2 sizeof (audioRouteOverride), // 3 and audioRouteOverride // 4);  

I disable the speaker below

  UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None; // 1 AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, // 2 sizeof (audioRouteOverride), // 3 and audioRouteOverride // 4);  

When I tried to check the contents of kAudioSessionProperty_AudioRoute as ASLOG (@ "% @", kAudioSessionProperty_AudioRoute); The simulator crashed.

I see the documentation, the CF string is almost identical to the NSString type. Therefore, it is appropriate to print the value of kAudioSessionProperty_AudioRoute to use NSLog.

As you said, kAudioSessionProperty_AudioRoute does not have to be "headphone" or "speaker" I still can, so the code I think is the paste is correct and by the way I am an active speaker I'm right, he is right. Can you give me a hand?

Your MacBook has only one speaker set, so you will only hear it from it. The phone has both receiver earpiece and the speaker on the bottom (which you want to use).

Just check what will be set as kAudioSessionProperty_AudioRoute .

kAudioSessionProperty_AudioRoute ... name of the current audio path (like "headphones," "speaker," and so on). A read-only CFStringRef value

More information about override the speaker property.

This property can only be used with kAudioSessionCategory_PlayAndRecord (or equivalent AVAudioSessionCategoryRecord) category. (...) By default, the output goes to the audio receiver for this category-when you hold your ear on a phone call. KAudioSessionOverrideAudioRoute_Speaker lets you direct the output audio of the speaker at the bottom of the phone.

kAudioSessionProperty_OverrideCategoryDefaultToSpeaker .. or does not specify the path to the audio (instead of the receiver for the audio), when the audio route, such as the headset, is connected. By default, the value of this property is incorrect (0).

This property retains its value on an audio path change (such as during plugging or unplugging in a headset), and on blockage; This only changes to an audio session category change in its default value. This property can only be used with kAudioSessionCategory_PlayAndRecord (or equivalent AVAudioSessionCategoryRecord) range.

See also kAudioSessionProperty_OverrideAudioRoute.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -