Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Silent mode in iOS5?

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...

like image 253
CCDEV Avatar asked Oct 17 '11 20:10

CCDEV


People also ask

How do I know if I have Silent mode?

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.

Where do I find the Silent mode?

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.

How do I find Silent mode on my iPhone?

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.

Where is Silent mode in settings on IPAD?

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.


2 Answers

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?

like image 62
Oliver Avatar answered Sep 21 '22 09:09

Oliver


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?

like image 21
Alon Amir Avatar answered Sep 22 '22 09:09

Alon Amir