UInt32 dataSize;
CFStringRef currentRoute;
currentRoute = NULL;
dataSize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &dataSize, ¤tRoute);
if([(NSString *) currentRoute hasPrefix: @"Headphone"])
{
//插入耳机后想执行的操作
}
CFStringRef currentRoute;
currentRoute = NULL;
dataSize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &dataSize, ¤tRoute);
if([(NSString *) currentRoute hasPrefix: @"Headphone"])
{
//插入耳机后想执行的操作
}