SHARE
TWEET

Untitled

a guest Jul 10th, 2013 47 Never
  1. [[AVSystemController sharedAVSystemController] setVolumeTo:0 forCategory:@"Ringtone"];
  2.        
  3. - (void) setSystemVolumeLevelTo:(float)newVolumeLevel
  4. {  
  5.     Class avSystemControllerClass = NSClassFromString(@"AVSystemController");
  6.     id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];
  7.  
  8.     NSString *soundCategory = @"Ringtone";
  9.  
  10.     NSInvocation *volumeInvocation = [NSInvocation invocationWithMethodSignature:
  11.                                       [avSystemControllerClass instanceMethodSignatureForSelector:
  12.                                        @selector(setVolumeTo:forCategory:)]];
  13.     [volumeInvocation setTarget:avSystemControllerInstance];
  14.     [volumeInvocation setSelector:@selector(setVolumeTo:forCategory:)];
  15.     [volumeInvocation setArgument:&newVolumeLevel atIndex:2];
  16.     [volumeInvocation setArgument:&soundCategory atIndex:3];
  17.     [volumeInvocation invoke];
  18. }
  19.        
  20. [[MPMusicPlayerController applicationMusicPlayer] setVolume:0];
RAW Paste Data
Top