0

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!

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90

1 Answers1

1

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.

Community
  • 1
  • 1
Sjoerd Perfors
  • 2,317
  • 22
  • 37
  • 1
    Talk about reviving an old unanswered question! Marked as correct even though I no longer have the source code to test it on, just to reward good behavior. – Paul Cezanne Oct 22 '15 at 13:41