iPhone - Can't adjust sound volume with hard buttons
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 changin开发者_JAVA百科g). - 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.
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
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
精彩评论