iOS 监听设备音量调节
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_observerApplicationVolumeAction:) name:KNotificationApplicationSystemVolumeDidChange object:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
- (void)_observerApplicationVolumeAction:(NSNotification *)sender {
if ([sender.name isEqualToString:KNotificationApplicationSystemVolumeDidChange]) {
NSLog(@"_observerApplicationVolumeAction");
}
}
#pragma mark App音量调节
#define KNotificationApplicationSystemVolumeDidChange @"AVSystemController_SystemVolumeDidChangeNotification"
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
NSLog(@"dealloc:%@",self);
}
本文标题:iOS 监听设备音量调节
本文链接:https://www.haomeiwen.com/subject/dgchzttx.html
网友评论