Reputation: 8741
I need to know (and control) my sound volume. I get it like this:
float volume = [[AVAudioSession sharedInstance] outputVolume];
NSLog([NSString stringWithFormat:@"MPVolumeView volume = %3.2f", volume]);
The float that prints is the volume that is set in my iPod. If I use the up and down volume buttons I see the volume overlay showing the correct ringer volume, not the iPod volume. Using the applicationMusicPlayer doesn't work either
float volume = [MPMusicPlayerController applicationMusicPlayer].volume;
This even happens in a sample app, the above lines are the only lines of code that I added to the stock "single view" project.
I only need an iOS6 solution but hey, if it works in older version I won't complain. Thanks!
Upvotes: 0
Views: 1010
Reputation: 2317
Check: Override ringer volume in iPhone apps
Add a dummy AVAudioPlayer and load it with a sound. Then just call prepareToPlay. Now you don't change the ringer anymore with the buttons.
Seems the app Waze is also doing this.
Upvotes: 1