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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- (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];
}
回答2:
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.
回答3:
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.
回答4:
you can use AVAudioPlayer and MPVolumeView for manage valume also please refer this link: How to implement a volume key shutter for iPhone?
回答5:
Try this code
float value = 0.5;//this should be between 0.0 to 1.0
[[MPMusicPlayerController applicationMusicPlayer] setVolume: value];