Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get System Volume iOS

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 current system volume is?

like image 585
Joris van Liempd iDeveloper Avatar asked Aug 31 '11 09:08

Joris van Liempd iDeveloper


People also ask

How do you check volume on iPhone?

Go to Settings > Sounds (or Settings > Sounds & Haptics), and drag the Ringer and Alerts slider back and forth a few times. If you don't hear any sound, or if your speaker button on the Ringer and Alerts slider is dimmed, your speaker might need service.

Why can't I adjust my iPhone volume?

If the buttons don't change anything, go to Settings > Sounds & Haptics, then check that Change with Buttons is turned on. Alternatively, you can alter the volume via the Control Center by swiping down from the top-right of your screen (iPhone X and later).


1 Answers

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)); 
like image 180
papahabla Avatar answered Sep 29 '22 23:09

papahabla