使用 MPMusicPlayerController 进行音量控制

Volume control with MPMusicPlayerController

我正在使用 MPMusicPlayerController 通过我的滑块更改系统音量:

-(void)viewDidLoad{
     MPMusicPlayerController musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
}

然后我实现了以下方法来改变声音:

-(IBAction)sliderValueChanged:(UISlider *)sender{
    [musicPlayer setVolume:  sender.value];
}
- (void)volumeChanged:(NSNotification *)notification
{
    float volume =[[[notification userInfo]   objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]floatValue];
    [self.volumSeekbar setValue:musicPlayer.volume];
}

当我用导引头改变音量时它显示了系统音量控制器,有什么办法可以防止显示吗?

edit: MPVolume 默认图像质量好但有点大!

这些是我使用的图片 - 我只包括了 1x 尺寸 - 拇指是 54 x 30

[self.mpVolumeView setMinimumVolumeSliderImage:[UIImage imageNamed:@"master_volume_bar"] forState:UIControlStateNormal];
[self.mpVolumeView setMaximumVolumeSliderImage:[UIImage imageNamed:@"grey_volume_bar"] forState:UIControlStateNormal];
[self.mpVolumeView setVolumeThumbImage:[UIImage imageNamed:@"volume_thumb"] forState:UIControlStateNormal];