您的位置:首页 > 移动开发 > IOS开发

iOS开发之音乐播放----监听系统音量变化

2014-08-28 09:36 405 查看
需要在:didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中加入一下监听事件:

<pre name="code" class="objc">    //监听系统音量控制
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];


然后实现对应的通知事件:

- (void)volumeChanged:(NSNotification *)notification
{
float volume =
[[[notification userInfo]
objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
floatValue];

NSLog(@"%f", volume);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios开发 音乐