zoukankan      html  css  js  c++  java
  • 获取系统当前音量 和 监听系统音量 ios

    -(float) getVolumeLevel
    {MPVolumeView*slide =[MPVolumeViewnew];UISlider*volumeViewSlider;for(UIView*view in[slide subviews]){if([[[view class] description] isEqualToString:@"MPVolumeSlider"]){
                volumeViewSlider =(UISlider*) view;}}float val =[volumeViewSlider value];[slide release];return val;}

    That should get you the current volume level. 1 is max volume, 0 is no volume. Note: no UI elements need to be displayed for this to work. Also note current volume level is relative to headphones or speakers (meaning, the two volume levels are different, and this gets you whichever the device is currently using. This doesn't answer your question regarding receiving notifications of when volume changes.

    AVSystemController

    + (id)sharedAVSystemController;

    - (void)getActiveCategoryVolume:(float*)outVolume andName:(NSString**)outName;

    Returns the volumn and name of the active category. Tells you whether headphones are plugged in.

    Notifications

    Sends a AVSystemController_HeadphoneJackIsConnectedDidChangeNotification notification when the user plus in or unplugs headphones.

    Sends a AVSystemController_SystemVolumeDidChangeNotification notification when the system volume has changed (via up/down buttons, mute switch, or programatically)

            [[NSNotificationCenterdefaultCenter] addObserver:self

                                                     selector:@selector(volumeChanged:)

                                                         name:@"AVSystemController_SystemVolumeDidChangeNotification"

                                                       object:nil];

     

    -(void)volumeChanged:(NSNotification *)notification {  [volumeViewSlider setValue:[[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue]]; }

     

     

     

    -(void)volumeChanged:(NSNotification *)notification {  [volumeViewSlider setValue:[[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue]]; }
     
     
     
     
     
  • 相关阅读:
    http://gzbbs.soufun.com/2811007370~59~471/4372594_4372594.htm
    借dudu的地方招个标,寻找广州网站开发外包公司
    System.InvalidOperationException: 哈希表插入失败。加载因子太高。
    网络艺术品交易黑洞
    水润麻涌
    麻涌蕉林香飘四季
    web开发的浏览器(工具)插件
    很好很强大的六个SEO关键词分析工具
    (转载)library cache lock和library cache pin到底是什么
    (转载)library cache lock和library cache pin到底是什么(续)
  • 原文地址:https://www.cnblogs.com/leevaboo/p/2923628.html
Copyright © 2011-2022 走看看