views:

165

answers:

1

I am using the AVAudioPlayer class to play .mp3 files in my App. Is it possible to check whether the earphones are connected to the device programmatically?

In first generation iPod devices, the volume control bar is hidden (for music and videos) when no earphones are connected.

+5  A: 

You can get the current audio 'route' by calling AudioSessionGetProperty with the kAudioSessionProperty_AudioRoute property. This gives you a string such as "Headphone" or "Speaker".

You can also use AudioSessionAddPropertyListener to listen for when the route changes (eg. disconnecting headphones)

See the apple docs here

Alex Deem