I have used this method in the past to detect if the silent switch is enabled:
- (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;
}
This is no longer working in iOS5 on my iPad or iPhone. Is this a known issue? I haven't been able to find any answers on stack overflow or Apple dev forums.
Hope you can help...
Press the "Up" volume button on the Android phone until the Silent Mode icon on the screen changes. The Silent Mode icon looks like a speaker with a line through it or a speaker with circle and a line superimposed over it. When the Silent Mode is disabled, only a speaker icon appears.
To turn on silent mode: Tap the lower part of the Volume key until the silent mode icon is displayed. If vibration is turned on, silent mode isn't turned on when you tap the Volume key.
The Ring/Silent switch is on the left side of your iPhone. You can use it to control which sounds play through your iPhone speaker.
Set sound options Go to Settings > Sounds. Drag the slider to set the volume for the ringer and alerts. Tap Ringtone and other options to select sounds for the ringtone and alert tones.
We won't be able to detect the silent switch state anymore since iOS 5...
The answer from Apple is there on the accepted answer : Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?
As mentioned in the iOS Developer Library, the property kAudioSessionProperty_AudioRoute is deprecated. Instead, Use the kAudioSessionProperty_AudioRouteDescription
https://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html
This question has been answered here: Detecting the iPhone's Ring / Silent / Mute switch using AVAudioPlayer not working?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With