Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting AVAudioPlayer volume to the user's ring volume?

I'm having a problem with AVAudioPlayer's volume.

I can set theAudio.volume property to 1.0, but I'd rather just play the audio at the volume the user has his iphone ringer set to.

Getting rid of the volume property defaults it at 1.0.

This seems trivial, but I couldn't find a reference to it anywhere.

Thanks a bunch!


1 Answers

The volume you set to a AVAudioPlayer instance is just a relative volume, for example if you wanna play two sounds, one at half volume of the other, you set the first one to 0.5 and the second to 1.0.

The real device volume is only controlled by the user and can't be change programaticly. (Audio & Video Coding How-To's - How do I access the hardware volume controller?)

You can add a MPVolumeView for the user the control the global volume.

like image 102
catlan Avatar answered Nov 18 '25 05:11

catlan