iOS 7: MPMusicPlayerController volume deprecated. How to change device volume now?

To answer you question exactly:
Yes there is other way to change system volume without user interaction.

Until recent times I used to think that changing volume using MPVolumeView programmatically is possible only using private API. But I have just verified, that changing the value of volumeSlider and faking slider’s touchUP event works:

MPVolumeView* volumeView = [[MPVolumeView alloc] init];

//find the volumeSlider
UISlider* volumeViewSlider = nil;
for (UIView *view in [volumeView subviews]){
    if ([view.class.description isEqualToString:@"MPVolumeSlider"]){
        volumeViewSlider = (UISlider*)view;
        break;
    }
}

[volumeViewSlider setValue:1.0f animated:YES];
[volumeViewSlider sendActionsForControlEvents:UIControlEventTouchUpInside];

(When slider receives touchUP event, it will invoke _commitVolumeChange method on itself, which will change the system volume)

Leave a Comment