- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
}
- (void)volumeChanged:(NSNotification *)notification{
float volume = [[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue];
//[self innerSetVolume:volume];
}
当我按下设备上的上/下硬件音量按钮时,不会调用volumeChanged。 有人遇到过这个问题吗?Objective-C:volumeChanged没有被调用,甚至添加一个Observer for AVSystemController_SystemVolumeDidChangeNotification?
PS:我的测试设备是iOS 4.3的iPod touch,而不是iPhone。
什么时候开始与AudioSessionSetActive音频对话? –
我想我没有,如何做到这一点? –
'AudioSessionInitialize(NULL,NULL,NULL,NULL); AudioSessionSetActive(true);' – srgtuszy