Created
September 29, 2012 01:20
-
-
Save hhyyy9/3802829 to your computer and use it in GitHub Desktop.
如何判断设备处于静音模式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL)silenced | |
{ | |
#if TARGET_IPHONE_SIMULATOR | |
// return NO in simulator. Code causes crashes for some reason. | |
return NO; | |
#endif | |
CFStringRef state; | |
UInt32 propertySize = sizeof(CFStringRef); | |
AudioSessionInitialize(NULL, NULL, NULL, NULL); | |
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize;, &state;); | |
if(CFStringGetLength(state) > 0) | |
return NO; | |
else | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment