AVAudioPlayer:音量按钮在某些设备上有效,在其他设备上无效
我有一个使用 AVAudioPlayer
来播放一些嵌入的 MP3 文件的应用程序。音量按钮在我主要用于测试的 3GS 上工作可靠——它们在 4.1 下工作,升级到 4.3.1 后现在可以工作。在我老板运行 4.2.1 的 iPhone 4 上,它们似乎根本无法在我们的应用程序中运行;在我的辅助测试机 iPod Touch(也运行 4.2.1)上,我已经能够让它们工作一次,但无法重现我是如何做到的。
我尝试了我发现的一种破解方法,在应用程序启动时创建一个虚拟的 AVAudioPlayer
但将其保留在 prepareToPlay
状态,并发现我能够在初始屏幕上使用音量按钮,但一旦我播放真实的音频,它们就停止工作了。
有人遇到过这个吗?知道为什么它适用于某些手机而不适用于其他手机吗?
更新:我将 Touch 更新到 4.3.1,问题就消失了。因此我认为这可能是 4.2.1 中的一个错误,但我仍然想知道是否有人看到它和/或可以向我指出错误报告。
I have an app that uses AVAudioPlayer
to play some embedded MP3 files. The volume buttons work reliably on the 3GS I mostly use for testing -- they worked under 4.1 and work now after upgrading to 4.3.1. On my boss's iPhone 4 running 4.2.1, they don't seem to work in our app at at all; and on the iPod Touch (also running 4.2.1) that's my secondary test machine, I've been able to get them to work once but can't reproduce how I did it.
I tried a hack I found, creating a dummy AVAudioPlayer
at application startup but leaving it in prepareToPlay
state, and found I was able to use the volume buttons on my initial screen, but once I was playing real audio they stopped working.
Anyone run into this? Any ideas why it works on some phones and not others?
Update: I updated the Touch to 4.3.1 and the problem went away. I assume therefore it's probably a bug in 4.2.1, but I'd still like to know if anyone's seen it and/or can point me to a bug report.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有同样的问题。我发现 YouTube 应用程序正在设置 AVAudioPlayer 上的默认音量。在 iPhone 4.3.3 上发现了这个,所以我不确定你是否已经摆脱困境了。
I had same problem. I found that the YouTube App was setting the default volume on the AVAudioPlayer. Found this with iPhone 4.3.3 so I am not sure if you are out of the woods yet.