When I use the device volume buttons to increase or decrease the volume, the volume I actually change is the phone's ringer volume. So if you decrease it and exit the app then your phone will ring quietly...

Is there an easy way to override this and actually change my application's volume?

2 Answers
2

I have found the solution to what I thought would be a common problem. So here is how your app can have its own volume, and not mess with the user's ringer volume, even if you are only playing sounds as System Sounds.

You have to import the AVFoundation framework and in an object that stays loaded the whole time your app runs (or view, or the app delegate) you have initialize a AVAudioPlayer, give it a file to play and set it to "prepareToPlay" it...

This is what i did in my main View (that is used to load other views as subviews):
in the header file:

Coming back a long time after I posted this, want to say that I found out that it only worked only for decreasing the volume and not increasing it... Anyway, I have been using AVAudioplayers ever since to play my sounds and rarely (if ever) play them through alerts.
–
DimitrisOct 22 '09 at 16:56

it is an old topic - but i wonder maybe the new sdk has some changes: i want my application to play a tone from file regardless of the ringer volume - and not even allowing the user to play with the volume or changing it. i want to be as loud as possible without any interference from the user (lowering the volume of the ringer or even putting it in mute mode - i still want to play the tone as loud) - what can i do? my code is using AvAudioPlayer and it is not working for me...
–
Itay LevinDec 1 '10 at 7:55

From what I can see in Apple's documentation, there are two issues here. 1. Application and the OS/hardware volume can only be controlled by the hardware/user. 2. You are playing a system sound. I believe the system sound is governed by the OS, so you're out of luck here, unless you are playing actual sound files. If you can use sound files, then take a look here.

I am playing sound files, I'm just playing them as System Sounds. Apple proposes to play short sounds (less than 30 seconds) this way. If it can't be done this way, I might have to do it the other way you are proposing. Thanks :)
–
DimitrisJun 25 '09 at 9:52