views:

46

answers:

1

Hi

Anyone could tell me how to detect when a jack of an earpiece is plugged-in into an ipad or iphone?

Thanks

+1  A: 

I believe you can call AudioSessionGetProperty and then get the value "kAudioSessionProperty_AudioInputAvailable" to detect whether an audio jack has been plugged in.

I.e.

AudioSessionInitilize(NULL, NULL, NULL, NULL);
UInt32 propertySize, micConnected;
AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable, &propertySize, &micConnected);
Daniel Frear
in which method should I include that piece of code.
okayasu
Well, i'm not an apple programmer but you'd want to call it when you need to check.For example, if you need to "wait" for an input device then you could display a screen waiting for it and call the AudioSessionGetProperty method in a loop with a timer (not sure what it is in x-code)
Daniel Frear