iphone - AVAudioPlayer声音太大

标签 iphone objective-c ios audio avaudioplayer

我已在我的 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/

相关文章:

javascript - iOS 溢出元素上的 Cordova Momentum 滚动

iphone - 如何查看 Facebook iOS 上传的进度?

ios - 在 Open ES iPhone 应用程序中围绕 VBO 使用 VAO 在调用 glDrawElements 时导致 EXC_BAD_ACCESS

iphone - 带有数字和默认键盘的 UITextField

ios - 格式化和操作数据库数据以在 tableview 中显示

ios - iPhone 应用程序在 iPad 上的兼容性

iphone - 构建数据驱动的 UI

ios - 看不到标签栏 Controller

iphone - 在 Instruments 中分析 iPhone 应用程序时缺少符号名称

ios - 无法正确突出显示段控件 ios