Skip to content

Instantly share code, notes, and snippets.

@khanlou
Last active October 9, 2019 01:31
Show Gist options
  • Save khanlou/9f86d0cf02f7d6bfdf114424c80821ce to your computer and use it in GitHub Desktop.
Save khanlou/9f86d0cf02f7d6bfdf114424c80821ce to your computer and use it in GitHub Desktop.
- (void)hideVolumeBezel {
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectZero];
volumeView.clipsToBounds = YES;
[self.view addSubview:volumeView];
}
- (void)beginDetectingVolumeClicks {
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:nil];
[audioSession setCategory:AVAudioSessionCategoryAmbient error:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
}
- (void)volumeChanged:(NSNotification *)note {
if ([note.userInfo[@"AVSystemController_AudioVolumeChangeReasonNotificationParameter"] isEqual: @"ExplicitVolumeChange"]) {
[self capturePhoto:self];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment