Georg
Georg

Reputation: 3920

iOS play sound file with constant volume, independent of user settings

Is there any way in iOS to keep playing a sound file at a constant sound volume? So no matter if the user did set the ringtone of his phone to very low volume, I still want to play my audio file at the same volume as if the phone was set to loud. Kind of like what Siri does. She's also independent of every other sound-volume setting.

Thanks

Upvotes: 3

Views: 1074

Answers (1)

Georg
Georg

Reputation: 3920

For everybody wondering. AVAudioPlayer has a property volume that can be set higher than 1. So you would figure out what the current device volume is using AVAudioSession.sharedInstance().outputVolume and then adjust the AVAudioPlayer volume to compensate the difference.

Note that the sound quality is not going to improve ;) So best thing is just to not do that ;)

Upvotes: 2

Related Questions