#import <AVFoundation/AVFoundation.h>
- (BOOL)isHeadphonePluggedIn {
AVAudioSessionRouteDescription *route = [[AVAudioSession sharedInstance] currentRoute];
for (AVAudioSessionPortDescription *desc in [route outputs]) {
if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones])
return YES;
}
return NO;
}
网友评论