开发者

Objective-C: volumeChanged wasn't called even add a Observer for AVSystemController_SystemVolumeDidChangeNotification?

- (void)viewDid开发者_如何学PythonLoad {
    [[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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜