【发布时间】:2015-08-17 09:07:50
【问题描述】:
我正在使用 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];
}
当我用搜索器改变音量时,它显示系统音量控制器,有什么方法可以防止显示?
【问题讨论】:
-
查看 MPVolumeView,这是系统提供的更改设备音量的方法。 developer.apple.com/library/ios/documentation/MediaPlayer/…
-
@amergin 谢谢,我正在使用 MPVolume,但我无法为其拇指图像设置好的图像。您知道要获得良好视野的尺寸应该是多少吗?
标签: ios volume mpmusicplayercontroller