0

Is possible to detect if volume hardware control is down or up? i need to play sound on button touch in my application, and i want to send a message to user that volume is down and to use this app he need to change hardware

EDIT:

I need to do something like this:

BOOL VolumeHardwareControl = getHardwareInfo();
if(VolumeHardwareControl==NO){
    message: "Attention! To play sound you need to turn hardware on!"
}else
   playSound();
Jayyrus
  • 12,961
  • 41
  • 132
  • 214
  • Lots of duplicate questions on this topic, Jack. Like [this one](http://stackoverflow.com/questions/572606/get-current-system-volume-level-on-iphone) and [this one](http://stackoverflow.com/questions/3651252/how-to-get-audio-volume-level-and-volume-changed-notifications-on-ios-4). – Michael Dautermann Nov 11 '11 at 10:19
  • these topic says about get current volume, not hardware. volume could be down but hardware on.. – Jayyrus Nov 11 '11 at 10:22
  • If you found an answer [you are welcome to post and accept your own answer](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/). – Jano Nov 11 '11 at 10:53
  • i have to create answer? – Jayyrus Nov 11 '11 at 10:55

1 Answers1

0
UInt32 routeSize = sizeof (CFStringRef);
CFStringRef route;

AudioSessionGetProperty (
                 kAudioSessionProperty_AudioRoute,
                 &routeSize,
                 &route
                );

if (route == NULL) {
    NSLog(@"Silent switch is on");
}
Jayyrus
  • 12,961
  • 41
  • 132
  • 214