iPod 音量影响应用程序音量
我正在编写一个 iPad 应用程序,它使用“Flite”文本转语音引擎来宣布特定事件。 Flite 引擎使用 AVAudioPlayer 实例在渲染后播放语音音频。为了好玩,我决定在我的应用程序中添加一些简单的控件,以允许用户在我的应用程序使用 MPMusicPlayerController 运行时控制 iPod 播放(下一首、上一首、播放/暂停和音量 - 基础知识)。
我遇到的问题是,当我使用 MPMusicPlayerController 调整 iPod 音量时,我的所有音频都会受到影响,包括其他音效和语音音频。在播放声音之前,我将这些其他音频播放器(AVAudioPlayer 实例)的音量设置为 1.0,但似乎音量始终限制在 iPod 播放器音量设置的范围内...
这正常吗?我能做些什么来解决这个问题?我希望我的应用程序的音频能够以系统最大音量播放,无论 iPod 播放器的音量级别如何。 (示例:用户将系统音量设置为设备最大音量的 80%。我希望我的应用程序以该 80% 的 100% 播放音频,同时允许用户将 iPod 音频播放调整为该 80% 的 0-100% %.) 注意:我对“闪避”不感兴趣,而是在我的应用程序运行时始终将 iPod 音量设置得较低(背景音乐)。
我也遇到这样的问题,有时,当您首次启动应用程序并按 iPod 播放器上的播放键(发送 [播放器播放] 调用)时,iPod 没有响应。如果我按下主页按钮,进入 iPod 应用程序并开始播放,然后,一旦返回到我的应用程序,它就可以正常工作。那有什么关系?
预先感谢您的任何帮助!
I am writing an iPad app that uses the "Flite" text-to-speech engine to announce specific events. The Flite engine uses an AVAudioPlayer instance to play the speech audio once it renders. For fun, I decided to add some simple controls to my app to allow the user to control iPod playback (next, prev, play/pause and volume - the basics) while my app is running using MPMusicPlayerController (of course).
The problem I am having is that when I adjust the iPod volume using MPMusicPlayerController, all of my audio is affected, including other sound effects and the speech audio. I set the volume for these other audio players (AVAudioPlayer instances) to 1.0 before playing the sound but it seems that the volume is always capped at whatever the iPod player volume is set to...
Is this normal? And what can I do to get around it? I want my app's audio to play at system full volume regardless of the volume level of the iPod player. (Example: The user had set the system volume to 80% of the device's max. I want my app to play audio at 100% of that 80% while allowing the user to adjust the iPod audio playback to 0-100% of that 80%.) Note: I am not interested in "ducking" but setting the iPod volume lower at all times while my app is running (background music).
I also have the problem, that -sometimes- when you first launch the app and press play on the iPod player (which sends the [player play] call), the iPod does not respond. If I press the home button, go into the iPod app and start playback then, once returning to my app, it works fine. What the deal with that?
Thanks in advance for any help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能与您指定的音频会话类别有关。查看音频会话编程指南 查看您是否选择了正确的类别。
It could be something to do with the audio session category you've specified. Check out the Audio Session Programming Guide to see if you've chosen the right category.
侧面的音量按钮控制系统音量,进而控制应用程序声音的音量。
我猜它被认为是主音量控制。
The volume buttons on the side control the system volume and by extension the volume of your app's sounds.
I guess it's considered to be the Master volume control.
设置特定样本或声音的音量。
您可以使用 AVItem 的 setVolume [item setVolume]
您可以创建一个 AVItem 来引用应用程序或 iphone 上的现有声音文件。代码非常简单,看起来像这样 -->
AVItem *item [[AVItem 分配]
initWithPath:@"文件"];
[项目集体积];
顺便说一句,这不会影响音频通道的其余部分(由某种 AVController 对象实例化),并且您在代码中设置的音量不会显示在屏幕上,所以我不确定是否可以在运行时更改它。
you can set the volume for specific samples or sounds using the AVItem's setVolume
[item setVolume]
You can create an AVItem to reference an existing sound file in your application or on the iphone. The code is pretty simple and looks like this -->
AVItem *item [[AVItem alloc]
initWithPath:@"the file"];
[item setVolume];
btw, this will not affect the rest of the audio channel (instantiated by some kinda AVController object) and the volume that you've set in your code will not be displayed on you screen so im not sure if you can change it at run time.