AVAudioPlayer 的 IOS 最大音量级别?
我使用 AVAudioPlayer 播放 .caf 文件。我的问题是:对于我的目的来说,声音不够响亮。由于 iPhone 的铃声更大,我想知道如何归档此卷。 我已经尝试操作 .caf 文件,但没有真正成功。有什么想法吗?
我到目前为止使用的代码:
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: url error: nil];
self.appSoundPlayer = newPlayer;
[newPlayer release];
[appSoundPlayer prepareToPlay];
[appSoundPlayer setVolume: 0.8];
[appSoundPlayer setDelegate: self];
[appSoundPlayer play];
编辑:
[appSoundPlayer setVolume: 1.0];
Thx 马丁
I use the AVAudioPlayer to play a .caf file. My problem is: it is not loud enough for my purpose. Since the ringer sound of the IPhone is much louder I was wondering how I can archive this volume.
I already tried to manipulate the .caf file but with no real success. Any ideas?
The code I use so far:
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: url error: nil];
self.appSoundPlayer = newPlayer;
[newPlayer release];
[appSoundPlayer prepareToPlay];
[appSoundPlayer setVolume: 0.8];
[appSoundPlayer setDelegate: self];
[appSoundPlayer play];
Edit:
[appSoundPlayer setVolume: 1.0];
Thx
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您始终可以将音量设置为实际最大值,例如:
除此之外,您可能必须编辑文件本身。
You could always set the volume to actual maximum eg:
Other than that, you probably will have to edit the file itself.
马丁,你确定系统音量开到最大了吗?如果没有,您需要使用 MPMusicPlayerController 将系统音量调到最大,而不仅仅是 avaudioplayer 的最大音量。您可以将其调高到声音剪辑的长度,然后将其设置回用户设置的原始音量。
Martin, have you ensured the system volume is to a maximum? If not, you want to use the MPMusicPlayerController to turn up the system volume to the max, and not just the avaudioplayer maximum. You can turn it up for the length of your sound clip and then set it back to the original volume the user had it set at.