【问题标题】:Is there a way to check the mute status? [duplicate]有没有办法检查静音状态? [复制]
【发布时间】:2011-07-24 16:02:57
【问题描述】:

可能重复:
How to programatically sense the iPhone mute switch?

我希望我的应用检查静音开关是打开还是关闭!但是有一个问题……有它的功能吗?

提前致谢

【问题讨论】:

    标签: ios xcode mute


    【解决方案1】:

    How to programmatically sense the iPhone mute switch?

    我相信这就是你要找的。​​p>

    在这里发布代码:

    // "Ambient" makes it respect the mute switch
    // Must call this once to init session
    if (!gAudioSessionInited)
    {
        AudioSessionInterruptionListener    inInterruptionListener = NULL;
        OSStatus    error;
        if ((error = AudioSessionInitialize (NULL, NULL, inInterruptionListener, NULL)))
        {
            NSLog(@"*** Error *** error in AudioSessionInitialize: %d.", error);
        }
        else
        {
            gAudioSessionInited = YES;
        }
    }
    
    SInt32  ambient = kAudioSessionCategory_AmbientSound;
    if (AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (ambient), &ambient))
    {
            NSLog(@"*** Error *** could not set Session property to ambient.");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 2022-01-15
      • 2022-10-12
      • 2015-03-27
      • 1970-01-01
      • 2014-01-17
      • 1970-01-01
      相关资源
      最近更新 更多