KishoreThindaak
KishoreThindaak

Reputation: 401

using AVSystemController in iPhone App

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

Upvotes: 2

Views: 2570

Answers (5)

Jim Clermonts
Jim Clermonts

Reputation: 2660

- (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];
}  

Upvotes: 4

iPhone Programmatically
iPhone Programmatically

Reputation: 1227

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.

Upvotes: 0

Shubham
Shubham

Reputation: 570

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

Upvotes: -1

Deepak Bharati
Deepak Bharati

Reputation: 280

Try this code

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

[[MPMusicPlayerController applicationMusicPlayer] setVolume: value];

Upvotes: -2

rckoenes
rckoenes

Reputation: 69499

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.

Upvotes: 0

Related Questions