使用滑块更改iphone sdk中AVAudioPlayer中的音量 [英] using slider change the volume in AVAudioPlayer in iphone sdk
本文介绍了使用滑块更改iphone sdk中AVAudioPlayer中的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
player.numberOfLoops = -1;
if (player == nil)
NSLog(@"%@",[error description]);
else
[player play];
但是我想更改音量,如何获取音量详细信息?
but i want to change the volume so how can i get the volume detail?
推荐答案
设置UISlider.注册它以在IB或以编程方式接收ValueChanged事件.将其最小值设置为0,将最大值设置为100.应该是这样.
Set up your UISlider. Register it to receive the ValueChanged events in IB or programmatically. Set its min value to 0 and max to 100. And that should be it.
- (void)sliderValueChanged:(UISlider *)slider {
myPlayer.volume = slider.value / 100.0;
}
这篇关于使用滑块更改iphone sdk中AVAudioPlayer中的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文