Get System Volume iOS

后端 未结 8 2259
死守一世寂寞
死守一世寂寞 2020-11-27 05:02

My case is simple: I need to play a warning signal and want to make sure the user will hear it, so I want to check the system volume.

How can I find out what the cur

8条回答
  •  春和景丽
    2020-11-27 05:38

    Update for Swift

        let vol = AVAudioSession.sharedInstance().outputVolume
    

    The audio session can provide output volume (iOS >= 6.0).

    float vol = [[AVAudioSession sharedInstance] outputVolume];
    NSLog(@"output volume: %1.2f dB", 20.f*log10f(vol+FLT_MIN));
    

提交回复
热议问题