MPMoviePlayerController - автоматически приостанавливается
прослушивание свойства kAudioSessionProperty_AudioRouteChange
#import <AudioToolbox/AudioToolbox.h>
void callbackHeadphone_func ( void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData ) {
if ( inID == kAudioSessionProperty_AudioRouteChange ) {
}
}
- (void) isHeadsetPluggedIn {
UInt32 routeSize = sizeof (CFStringRef); CFStringRef route;
AudioSessionGetProperty (kAudioSessionProperty_AudioRoute, &routeSize, &route);
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, callbackHeadphone_func, self);
/* Known values of route:
"Headset"
"Headphone"
"Speaker"
"SpeakerAndMicrophone"
"HeadphonesAndMicrophone"
"HeadsetInOut"
"ReceiverAndMicrophone"
"Lineout" */
NSString* routeStr = (NSString*)route;
NSLog(@"%@",routeStr);
}