Search code examples
iphoneaudiovolume

get current system volume level on iPhone


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.


Solution

  • 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;