iPhone - 无法使用硬按钮调节音量
当我的应用程序启动时(没有发出声音,为 AudioSession 设置环境类别),使用 iPhone 上的向上和向下音量按钮不会执行任何操作: - 屏幕上没有显示任何内容(我的意思是,iOS 黑白“滑块”覆盖层似乎没有向我显示音量正在变化)。 - 在应用程序中,使用硬按钮播放后,播放某些声音时对音量没有影响(我使用 AVAudioPlayer) 之前的声音级别相同
- 如果我退出应用程序,调整音量(屏幕上的“滑块”覆盖层显示,例如,向我显示声音级别已降低),关闭应用程序并重新启动它:与使用这些 硬按钮可以在跳板上和其他应用程序中工作(显示“滑块”覆盖并且音量正在变化)。
我的应用程序有什么问题?
据我所知,许多应用程序(例如愤怒的小鸟)都会发出声音,在玩游戏时没有硬滑块来改变音量,只需使用硬按钮即可调整声音。
When my app is launched (no sound emitted, Ambiant category set for AudioSession), using the up and down volume button on the iPhone does not do anything :
- on screen, nothing is displayed (I mean, the iOS black and white "slider" overlay does not appear to show me that volume is changing).
- in app, after playing with hard buttons, no impact on the sound volume when some sound is played (I use an AVAudioPlayer)
- this is the same if I quit the app, adjust the sound volume (onscreen "slider"overlay shows up to show me that the sound level have decreased for example), kill the app and relaunch it : same sound level that before
Using those hard buttons work though on the springboard and into other apps ("slider" overlay is displayed and volume is changing).
What is the problem with my app ?
As far as I've seen, many app, and angry birds for an example, make sounds, does not have a hard slider to change it's volume when playing game, and sound can be adjusted just playing with hard buttons.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的应用程序的一些用户也遇到了同样的问题,这不是我的代码,而是他们的 iPhone 设置:
转到“设置”->“声音”->“使用按钮更改”并将其设置为“关闭”
I got some users of my app with the same problem, it was not my code but their iPhone settings:
Go to Settings->Sound->Change with Buttons and set it to Off
您的应用程序如何处理这些内容取决于您如何设置音频会话。我记得有五个不同的类别可供选择。您选择的类别会影响您的应用程序在硬件按钮、音量、背景等方面的行为方式。
最好的办法是在这里查看Apple文档:
http://developer.apple.com/library/ios/#DOCUMENTATION/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html#//apple_ref/doc/uid/TP40007875-CH3-SW1
另外,Apple 有一个非常棒的教程视频,很好地介绍了这些内容。这是链接:
https://developer.apple.com/videos/iphone/ #视频高级音频开发
How your app behaves with that stuff depends on how you have set up your audio session. There are as I recall five different categories to choose from. Which category you choose affects how your app behaves with respect to hardware buttons, volume, backgrounding, and so on.
Best bet is to have a look at the Apple docs here:
http://developer.apple.com/library/ios/#DOCUMENTATION/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html#//apple_ref/doc/uid/TP40007875-CH3-SW1
Also, there is a really great tutorial video by Apple that covers this stuff really well. Here's the link:
https://developer.apple.com/videos/iphone/#video-advanced-audiodev