Created
November 25, 2014 18:00
-
-
Save grundyoso/cfd2d1095a0a01f73a91 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
- (void)playNotification { | |
// _reader.mute = YES; // Mute AudioJack library | |
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]; // Route audio to speakers | |
AudioServicesPlaySystemSound (1312); // Only device support. see codes: https://github.com/TUNER88/iOSSystemSoundsLibrary | |
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil]; // Route audio back to Headphones | |
// _reader.mute = NO; // Unmute the AudioJack library | |
} | |
/** | |
* Detect when the audio route has changed manage when Headphone jack is plugged/unplugged so as to never hear the AudioJack tone | |
* @param notification the notification registered | |
*/ | |
-(void)handleRouteChange:(NSNotification*)notification{ | |
AVAudioSession *session = [AVAudioSession sharedInstance]; | |
AVAudioSessionPortDescription *input = [[session.currentRoute.inputs count]?session.currentRoute.inputs:nil objectAtIndex:0]; | |
if ([input.portType isEqual: @"MicrophoneBuiltIn"]) { | |
// TODO: show FloJack unplugged image | |
// _reader.mute = YES; // Mute AudioJack library | |
} else if ([input.portType isEqual: @"MicrophoneWired"]) { | |
// TODO: show FloJack plugged-in image | |
// _reader.mute = NO; // Unmute the AudioJack library | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment