views:

1964

answers:

2

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  A: 

I follow the hardware changes by setting this callback

AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume, audioVolumeChangeListenerCallback, self);

But for some reason I think I concluded that getting the initial state required a non-published API call. I can't remember at the moment. Maybe this info will get you started in the right direction!

John Fricker
+3  A: 

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.

catlan