Reputation: 43
- (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 will not be called when I push the up/down hardware volume button on device. somebody met the question before?
PS:my test device is iPod touch with iOS 4.3, not iPhone.
Upvotes: 4
Views: 2733
Reputation: 89549
I believe you need to start up Audio Session Services in order for those notifications to fire.
Here's the documentation for the call -- http://developer.apple.com/library/ios/documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html#//apple_ref/c/func/AudioSessionSetActive
Upvotes: 2