Advertisement
Guest User

Untitled

a guest
Jul 10th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  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];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement