0

I am developing app using AVAudioPlayer and I want to detect the volume level of my devices i.e. iPhone/iPad then How can I do it?

Actually I want to detect when the iPhone/iPad is in silent mode then what is its volume level?

Any Idea? share it.

thanks,

kEvin
  • 411
  • 6
  • 18

1 Answers1

0
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(volumeChanged:)
     name:@"AVSystemController_SystemVolumeDidChangeNotification"
     object:nil];
}

- (void)volumeChanged:(NSNotification *)notification
{
    float volume =
    [[[notification userInfo]
      objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
     floatValue];

    // Do stuff with volume
}

Please see the answer details on this thread.

Community
  • 1
  • 1
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102