tags:

views:

186

answers:

1

I'm writing an app that uses AVAudioPlayers to play sounds and I need the sounds to play at absolute MAX volume. Yes you can set the relative volume for an AVAudioPlayer, but if the user has the device volume turned down, the sound will still play quietly.

I know that Apple says that the device volume cannot be overridden, but yet the Alarm Clock apps out there somehow are able to do this - so there must be a way.

I believe that this can be done using Audio Queues using the call:

AudioQueueSetParameter(aq, kAudioQueueParam_Volume, 1.0);

But my code needs to use the AVAudioPlayer to play the sounds so I don't think this approach will be of any help.

There is also a way to use an undocumented function of MPVolumeView to accomplish this, but apparently someone already had an app rejected for using this method.

Any other ideas?

A: 

I came across this:

 MPVolumeView *volumeView1 = [[MPVolumeView alloc] initWithFrame:CGRectMake(4, 316, sk.size.width, sk.size.height)]; 
[volumeView1 sizeToFit]; 
[self.view addSubview:volumeView1]; 
[volumeView1 release]; 

I'm not entirely sure if it will work, but I believe it should. It seems you might have to modify the height and width

Matt S.
Thanks, but that will just present a slider control that will allow the user to adjust the device volume. I just need to max it out without any user involvement. I guess as a fallback I could present the slider and some text saying "Please slide this all the way over to the right" - but that is really tacky.
Bradley4040
why don't you just have them set the volume themselves, it'll improve the user experience
Matt S.
I'm writing an alarm clock app and they all max out the device volume. If you don't, it's certain that you'll get reviews like "This app sucks: the alarm didn't go off and I missed my test!". The fact that they had the volume all the way down doesn't enter into the equation.
Bradley4040
Then just have the volume slider stand out. Do some UI skinning. Not everybody likes to wake up to loud noises. I personally prefer to wake up to about half volume. It wakes me up, but slowly, so I don't feel really tired when I do wake up
Matt S.