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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With