Minestroni-Soup Minestroni-Soup - 1 year ago 96
iOS Question

Get current volume of device sound output - iOS

I am playing a song in the background of my app (with

) and I want to have some bars bouncing up and down similar to in Garageband where you set a track's volume. I want to know how to get the current volume of the song playing, not the volume the device is set at.

Thanks in advance

Answer Source

You are asking about metering, not volume. See the docs for AVAudioPlayer. You need to use the various APIs for metering such as meteringEnabled and averagePowerForChannel:.

Apple provides a sample app that demonstrates this. See the avTouch sample app.

And you can find plenty of discussions here on Stack Overflow. See these search results.