2

I want to reduce the ringing volume of iPhone programmatically, I came to know that it is possible with AVSystemController, But I know, it is a private method. If I use it, will apple reject the app or please suggest me the alternative way

sunkehappy
  • 8,970
  • 5
  • 44
  • 65
KishoreThindaak
  • 391
  • 2
  • 4
  • 14

5 Answers5

4
- (void) setSystemVolumeLevelTo:(float)newVolumeLevel
{
    Class avSystemControllerClass = NSClassFromString(@"AVSystemController");
    id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];

    NSString *soundCategory = @"Ringtone";

    NSInvocation *volumeInvocation = [NSInvocation invocationWithMethodSignature:
                                  [avSystemControllerClass instanceMethodSignatureForSelector:
                                   @selector(setVolumeTo:forCategory:)]];
    [volumeInvocation setTarget:avSystemControllerInstance];
    [volumeInvocation setSelector:@selector(setVolumeTo:forCategory:)];
    [volumeInvocation setArgument:&newVolumeLevel atIndex:2];
    [volumeInvocation setArgument:&soundCategory atIndex:3];
    [volumeInvocation invoke];
}  
Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
0

Using any kind of private method there is the change of Apple rejecting your app. Since the public iOS SDk does not allow you to change the ringer volume, you will not be able to this from your app.

rckoenes
  • 69,092
  • 8
  • 134
  • 166
0

Possible yes, apple will reject it. Here is the link that will tell you how to do this.[link2

Update:

[[MPMusicPlayerController applicationMusicPlayer] setVolume:setvalue];

Check theselink link also. You cannot change the ringer volume programmatically.

Community
  • 1
  • 1
iPhone Programmatically
  • 1,211
  • 2
  • 22
  • 54
-1

you can use AVAudioPlayer and MPVolumeView for manage valume also please refer this link: How to implement a volume key shutter for iPhone?

Community
  • 1
  • 1
Shubham
  • 570
  • 3
  • 12
  • The question is about the phone ringer volume not the audio playback volume. – rckoenes Jan 16 '14 at 09:04
  • have you checked the link which i have provided ? – Shubham Jan 16 '14 at 09:09
  • Yes I did, it a talking about a hack to detect the pressing of the plus volume button. But this question is about programmatically change the ringer volume, not the audio playback volume. – rckoenes Jan 16 '14 at 09:15
-2

Try this code

float value = 0.5;//this should be between 0.0 to 1.0

[[MPMusicPlayerController applicationMusicPlayer] setVolume: value];
Deepak Bharati
  • 280
  • 2
  • 13