Skip to content

Instantly share code, notes, and snippets.

@grundyoso
Created November 25, 2014 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grundyoso/cfd2d1095a0a01f73a91 to your computer and use it in GitHub Desktop.
Save grundyoso/cfd2d1095a0a01f73a91 to your computer and use it in GitHub Desktop.
- (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