Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 10th, 2013  |  syntax: None  |  size: 0.98 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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];