views:

378

answers:

1

How do I determine programatically whether or not the iPhone is in manner mode? And is there a way to tell if the headphones are connected?

Edit: This is also called silent mode in some parts of the world.

+3  A: 

There appears to be an example here on http://www.iphonedevsdk.com/forum/iphone-sdk-development/21456-detect-wheather-phone-silent-mode-ring-mode.html

Reproduced here From Narender Mugdal:

CFStringRef route;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_Audi oRoute, &propertySize, &route);
NSString *outputString = (NSString*)route; 
//NSLog(@"%@", outputString);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message: outputString delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
Preet Sangha