Reputation: 22587
I know you cannot control device volume from within your application, but I would like the device volume to be able to affect the UIScrollBar I have in my application to control volume.
I know this is possible because the Last.fm application does it, I would like to implement this behaviour.
I can find very little information on the interwebs. Anyone here can help me maybe? :)
Upvotes: 5
Views: 5134
Reputation: 3334
It's easy with a listener callback
void audioVolumeChangeListenerCallback (void *inUserData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData)
{
RootViewController *controller = (RootViewController *) inUserData;
Float32 newGain = *(Float32 *)inData;
[controller setGainManual:newGain];
}
which gets initialized in my view controller's viewDidLoad like this
AudioSessionAddPropertyListener (kAudioSessionProperty_CurrentHardwareOutputVolume ,audioVolumeChangeListenerCallback, self );
This is all SDK/App Store friendly too.
Upvotes: 15