读书人

如若获取耳机插入的事件

发布时间: 2012-09-04 14:19:30 作者: rapoo

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

读书人网 >移动开发

热点推荐