1

I want to completely reduce the volume in iPhone to 0. And also I want to know is there a way to programmatically turn iPhone to vibrating mode. I did some work and in that I'm not completely able to make volume to 0. I make volume to 1 when call [self setSystemVolumeLevelTo:0]. Help Me guys ...

- (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];    
} 
Lucas Huang
  • 3,998
  • 3
  • 20
  • 29
Jaffer Sheriff
  • 1,444
  • 13
  • 33
  • I'm pretty sure you can't turn an iPhone to vibrate programmatically, because the vibrate setting is controlled by the user with the switch on the side of the phone – Bagelman Jan 27 '15 at 17:56
  • possible duplicate of [Increase volume programmatically](http://stackoverflow.com/questions/7138180/increase-volume-programmatically) – Lucas Derraugh Jan 27 '15 at 18:13
  • But how can I make the volume to 0 with above code – Jaffer Sheriff Jan 28 '15 at 05:45

0 Answers0