/MuteDetector

Helper class to detect mute switch state

Primary LanguageObjective-C

MuteDetector

Helper class to detect mute switch state

Due to the recent need of detecting mute switch state, I've found SharkfoodMuteSwitchDetector by Moshe Gottlieb (Sharkfood - http://sharkfood.com/archives/450).

This is simply a small redesign of the Moshe's solution to make it easily usable for those of us who simply want to quickly check its state (instead of actively watching it).

Usage

  • Add SKMuteSwitchDetector.h and SKMuteSwitchDetector.m to your project
  • Add AVFoundation.framework to your project
  • Import SKMuteSwitchDetector.h in your class and use it as simply as (taken from this demo project SKViewController.m):
    [SKMuteSwitchDetector checkSwitch:^(BOOL success, BOOL silent) {
        NSString *message;
        if (success) {
            message = [NSString stringWithFormat:@"Mute switch is %@", silent ? @"ON" : @"OFF"];
        }
        else {
            message = @"Failed to detect mute switch state";
        }
        [[[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
    }];