-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/fopina/MuteDetector
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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, SKMuteSwitchDetector.m and mute.caf_ 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_): | ||
|
||
```objective-c | ||
[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]; | ||
}]; | ||
``` |