8

The FoneHome iPhone app has a feature where you can play a sound as part of a local notification. That sound is loud regardless of what the iPhone's volume level is set at.

How is it possible to get a local notification (or push) to play an audio alert that is loud independent of what the current iPhone volume level is? I tried just setting the soundName to a WAV file but it plays at whatever the current volume is, and I see no options to set it otherwise.

puot
  • 161
  • 1
  • 7
  • FoneHome runs in the background continuously, and uses something other than push notifications to play sounds. – Greg Jul 17 '11 at 12:38
  • 5
    You can do whatever you want in your app but putting something like this would be violating user's control over their own device. If i turn down the volume i want it to stay that way. – Bushra Shahid Jul 22 '11 at 08:12

1 Answers1

2

Try using the following code

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[audioPlayer setVolume:x];
if (audioPlayer == nil)
    NSLog([error description]);             
else 
    [audioPlayer play];

Here 'x' is a floating point value which normally ranges from 0.0 to 1.0. However to increase the Volume level assign x value >10.0. But doing this may distort the sound a bit.

james lobo
  • 463
  • 4
  • 10