2

I am developing an Iphone/Ipod Application, in which I am using AVAudioPlayer. I am changing volume of audio through slider, which works correctly, but now I have to change(increase/decrease) slider by pressing the device plus and minus button instead of changing slider by myself. When I press plus/minus button of device, don't know where the control goes? Does anybody know, feel free to help.

Khalid Usman
  • 1,272
  • 1
  • 13
  • 32

3 Answers3

2

How do I access the hardware volume controller?

Global system volume, including your application's volume, is handled by iPhone OS and is not accessible by applications.

Here is link kindly read it here Hope it will help you :)

Zaksh
  • 953
  • 2
  • 12
  • 29
1

The question isn't entirely clear to me, but it seems you're wanting a notification when the system volume changes? If so, this is possible, I hope I understand your question correctly. How about the following:

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(volumeChanged:)
     name:@"AVSystemController_SystemVolumeDidChangeNotification"
     object:nil];
}

- (void)volumeChanged:(NSNotification *)notification
{
    float volume =
    [[[notification userInfo]
      objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
     floatValue];

    // Do stuff with volume
}

I grabbed this from here, Sandy's answer.

Community
  • 1
  • 1
Paul
  • 11
  • 3
  • Thanks for reply, but i have already visited it. I just want to know that where I can receive response after pressing plus/minus button on device. – Khalid Usman Feb 10 '12 at 13:39
  • hello @paul , would u pls tell me .. here the volume is changing through buttons what it is said to be as?. Ringer volume of device volume of audioplayer volume? – Prince Kumar Sharma Sep 29 '12 at 07:18
0

Slam and thanks all! I have searched on it. This is valid for MPMusicPlayer, but not for AVAudioPlayer. You can do it.

MPMusicPlayerController *_musicController = [MPMusicPlayerController iPodMusicPlayer];

But not this for AVAudioPlayer,

AVAudioPlayer *_audioController = [AVAudioPlayer iPodMusicPlayer];
Khalid Usman
  • 1,272
  • 1
  • 13
  • 32