1

Possible Duplicate:
play sound on iphone even in silent mode

I'm trying to play a short sound (which denotes the completion of a timer) and have implemented it as a system sound. Since my app is a timer, I would like for the sound to be audible even if the mute switch is enabled.

// Load the sound

NSString *path = [[NSBundle mainBundle] pathForResource:@"tinshaw"
                                                 ofType:@"wav"];
NSLog(@"tinshaw: %@", path);
NSURL *pathURL = [NSURL fileURLWithPath:path];

// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID ( ((__bridge CFURLRef)pathURL), &completionSound);

// Play the Sound
AudioServicesPlaySystemSound(completionSound);

I have tried changing the audio session category to "AVAudioSessionCategoryPlayback", but that didn't work. Is there

Community
  • 1
  • 1

2 Answers2

-4

Think about what you're asking for a second. What good is a mute switch if a 3rd party app can choose to ignore it and play sounds anyway?

There are some exceptions to when sounds will play when a device is muted, but those aren't for 3rd party apps.

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128
  • 1
    It does depend on what he's doing... Interesting blog post on the topic http://www.marco.org/2012/01/14/mute – evanmcdonnal Jun 02 '12 at 00:59
  • @Shaggy Frog: The mute switch on the iPhone is not viewed as a mute to all sounds, even by Apple itself. In Apple's documentation, they mention that there are instances where sound should be audible despite the mute switch - I just didn't know how to accomplish this. The way I view it: if a user explicitly performs an action with the intent of hearing sound, then the sound should be played regardless of the current mute switch position (think the timer or YouTube app). The mute switch should always, however, mute any alert sounds or application sounds not explicitly requested by the user. –  Jun 02 '12 at 14:38
  • Appreciate this is old but for anyone searching (like myself) @evanmcdonnal and user1431759 are right in that some instances the expected behaviour is to play sound (e.g. music players). The switch is to mute ringers/alerts but not user invoked sounds. – DannyT Jun 26 '14 at 13:37
-4

+1 to @Shaggy Frog. Even though there are API's for playing sounds regardless of mute switch status, they are most definitely private. So, basically, the answer to your question is it cannot be done. What you COULD do, however, is use some sort of alert message every time the application launches (in the viewDidLoad method) to politely remind your user to keep their phone unmuted if they would like alerts from your app.

Radrider33
  • 557
  • 1
  • 4
  • 17