get current system volume level on iPhone

Sophie Alpert picture Sophie Alpert · Feb 21, 2009 · Viewed 14k times · Source

Is there a way I can get the current system volume level on the iPhone?

I'm thinking maybe there's a way to make an MPVolumeView and get the value from that.

Answer

amergin picture amergin · Oct 24, 2011
musicPlayer = [[MPMusicPlayerController iPodMusicPlayer];

currentVolume = musicPlayer.volume;

This is now deprecated as of iOS8.0 so try the following

#import <AVFoundation/AVAudioSession.h>

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
CGFloat volume = audioSession.outputVolume;