iOS: Change Device Volume iOS: Change Device Volume ios ios

iOS: Change Device Volume


Using iPodMusicPlayer would affect the actual iPod volume setting as well. If you want to avoid that, use this:

#import <MediaPlayer/MediaPlayer.h>// ...MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer];musicPlayer.volume = 1.0f; 

As the user holex correctly mentioned the property volume in MPMusicPlayerController is deprecated in iOS 7.


You can use a little trick:

  MPMusicPlayerController* musicPlayer = [MPMusicPlayerController iPodMusicPlayer];  musicPlayer.volume = 1; // device volume will be changed to maximum value


You cannot change device volume programatically, however MPVolumeView (volume slider) is there to change device volume but only through user interaction.

MPVolumeView is a control in toolbox, you need to add MediaPlayer.framework in your project then MPVolumeView will be displayed in toolbox in interface builder.

Edit 1: MPVolumeView uses the device volume which is also used for ringing volume. AVAudioPlayer is there if you want application level volume. In this case you can use volume property to set your application volume (not device volume) programatically. However, you can use UISlider control to get volume input from user and set to your AVAudioPlayer