我已在我的 iPhone 应用程序中实现了 AVAudioPlayer,但播放的音频声音太大。为了让声音稍微安静一些,我把音量调到了0.2f,看看有没有效果。音量保持完全相同。这是我正在使用的代码:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Blip.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
[audioPlayer setVolume:0.2f];
if (audioPlayer == nil)
NSLog(@"Whoopsies, there was an error with the sound!");
else
[audioPlayer play];
为什么这不会降低音量?
有人可以解释一下我该怎么做吗?
谢谢!
最佳答案
替换您的代码:
[audioPlayer setVolume:0.2f];
使用以下代码:
audioPlayer.volume = 0.2;
希望对你有帮助。
关于iphone - AVAudioPlayer声音太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9478366/