views:

239

answers:

1

Hey!

I want to check wether or not the iPhone is muted when the app starts, and I want some code to be run every time the mute-switch switches.

Is this possible?

Thanks :)

EDIT: I use an AVAudioPlayer to play sounds.

What I am trying to do is to set the text of a label, if the phone is muted, in viewDidLoad:, and edit the text again every time the state of the mute-switch changes.

+2  A: 

See this post
http://stackoverflow.com/questions/287543/how-to-programatically-sense-the-iphone-mute-switch

Romain Hippeau
That only answers half of my question.
Emil
@Emil I am confused, If you can detect then you can write code based on the condition being true or false.
Romain Hippeau
Sorry, that didn't help at all..I want to know how I can check if the phone is in mute mode, and how I can get warned about the mute-switch-state shifting.
Emil
@Emil If you follow this http://inforceapps.wordpress.com/2009/07/08/detect-mute-switch-state-on-iphone/ you will see that you can play a silent sound clip and detect if mute is on or not. There is no way to be notified as it stands currently. You are going to need to poll.
Romain Hippeau
Okay.. Thank you.
Emil