iPhone Dev: Detect if the iPhone's in Silent Mode
I have been writing an application that delivers audio to the user using the AVAudioPlayer, apart of the AVFoundation. If the iPhone is in Silent mode, then the audio isn't heard, however from the applications point of view the audio has been played. If the iPhone is in Silent mode, I want to warn the user so they know that when they press the button that plays sound, they're not going to hear any.
The following function is based on some info I found scattered around on forums, as well as some of my own tinkering to actually get it to work. It will return a boolean indicating if you will be able to play audio using the AVAudioPlayer.
Note: If the iPhone is in Silent mode with headphones attached, this function will return true, and the AVAudioPlayer should still be able to play audio.
The following function is based on some info I found scattered around on forums, as well as some of my own tinkering to actually get it to work. It will return a boolean indicating if you will be able to play audio using the AVAudioPlayer.
- (bool)isAudioEnabled {
UInt32 cfRouteSize = sizeof (CFStringRef);
CFStringRef cfRoute;
NSString* nsRoute;
AudioSessionGetProperty(
kAudioSessionProperty_AudioRoute,
&cfRouteSize,
&cfRoute);
nsRoute = (NSString*)cfRoute;
return ([nsRoute length] == 0);
}
Note: If the iPhone is in Silent mode with headphones attached, this function will return true, and the AVAudioPlayer should still be able to play audio.
Labels: iPhone
I was recently graced with the frustration of monitor troubles on a Apple Mac Mini. A family member bought a Mac Mini, with the intention of using their previous LCD monitor with it. Save on costs, so on, just how Apple promote their product.
Bake the potatoes in the oven, until cooked, probably 90 minutes. About 15 minutes out from the potatoes being ready, mix all the other ingredients together in a pot on the stove until vegetables are cooked to your liking.

