添加事件监听
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeDidChange:)name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
事件回调
- (void)volumeDidChange:(NSNotification *)notification
{
double i= [(NSNumber *)notification.userInfo[@"AVSystemController_AudioVolumeNotificationParameter"] doubleValue];
NSLog(@"=当前音量:%f",i);
}
网友评论