views:

1720

answers:

1

Some iPhone applications, such as Pandora seem to directly manipulate the hardware volume and respond to physical volume button. How is this done?

AudioSessionServices allows you to get the current hardware output volume with the kAudioSessionProperty_CurrentHardwareOutputVolume property, but it is (allegedly) read-only.

+5  A: 

They use the MPVolumeView, simple add it and it's makes the rest when the user touch it. Note: Doesn't work in iPhone Simulator. I think the release note also mentioned do not use it direct in Interface Builder.

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];
[self.view addSubview:volumeView];
[volumeView release];
catlan