system volume

Is there a way to programmatically control the system volume of an iPhone device using Swift? Not the volume as controlled by AVAudioPlayer, but the system volume -- like when you press the volume buttons on the side of the device.

Answered by theanalogkid in 156191022

The overall system output & alert volumes of the device are user preferences so no APIs. You can control relative volume if you wish and you can use the MPVolumeView to give a user the option to control output volume from within your app. The language isn't going to make a difference.

Accepted Answer

The overall system output & alert volumes of the device are user preferences so no APIs. You can control relative volume if you wish and you can use the MPVolumeView to give a user the option to control output volume from within your app. The language isn't going to make a difference.

How do I control the volume with code other than with the MPVolumeView? Hasn't the .volume property been deprecated?

I saw an app control the volume of music which showed the gray and white display with a picture of a speaker and the white progress bar, like the one you see when you use the volume buttons on the side of the iPhone. Do you think that the programmers might have jailbroken the code?

No, you're confusing MPVolumeView and MPMusicPlayerController which did indeed have a volume property that was deprecated in iOS 7 and a comment next to the property in the header file saying "-- use MPVolumeView for volume control instead." MPVolumeView may present a slider and output routing controls which the user can then set as is their preference.

system volume
 
 
Q