tags:

views:

566

answers:

3

When I use my app (on the device), the actual volume works OK for a while, but after a few days it seems to get 'stuck' at a low level. Adjusting the volume rocker has no effect - and it show 'Ringer' text... I've noticed that other people's apps are similarly affected if they show the 'Ringer' text when adjusting the volume. But apps which don't show 'Ringer' text are not effected by this.

How would I remove the 'Ringer' text and get my app to respond properly to different volumes?

A: 

I found some code on Apple's forums which fixes it. You have to use the AVFoundation.framework and put a bit of code into your app delegate. And put an audio file called 'blank.aif' into your project. Basically, it's a hack which prepares a file to play, but then never plays it. This fools the system into thinking that sound is being played all the time, which allows the user to use the main volume control.

#import <AVFoundation/AVFoundation.h>

//...


-(void)applicationDidFinishLaunching:(UIApplication *)application {

//volume control hack
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"blanksound" ofType:@"aif"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath];
AVAudioPlayer *volumeHack = [[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]retain];
[fileURL release];
[volumeHack prepareToPlay];

// other applicationDidFinishLaunching stuff
}
cannyboy
A: 

Could someone share blank aif sound please?

Dmitry
A: 

Thank you! This hack did just the trick for me. Dmitry - it can be any sound file - it doesn't need to be blank.aif

Jonathan Cohen